php Cannot call the function for array_map
<p>I am using php 5.2.10 i want to do the array_map on the array and i created a function for array mapping </p>

<pre><code>function get_result(){
    $result = mysql_query("Select * from table");
    while($cr = mysql_fetch_array($result)){
        $b = array_map(`calc`,$cr);
        $rr_id = $cr['batch_id'].$cr['seq_id'];
  $mqrrid = '999'.$rr_id;
  $question_id = $cr['question_id'];
        foreach ($b as $k =&gt; $v){
            if(preg_match('{^Item \d+$}',$k)){
                $new_insert[] = array(
                    'r_id'=&gt;$mqrrid,
                    'q_id' =&gt;$q_id,
                    'c_id' =&gt;$k,
                    'rank'=&gt;$v
                );
            }
        }
    }
}   

function calc($n){
    foreach($n as $m=&gt; &amp;$x) {
        if (preg_match('{^Item \d+$}', $m)) {
            if($x == null){
                $x = $x;
            }else {
                $x = $x - 1;
            }
        }
    }   
    return $n;
}
</code></pre>

<p>I don't know why I cannot call the function <code>calc</code> in <code>array_map</code>.....I cannot figure out the reason.....
Can anyone help me ?                                            </p>

<p>original array :( actually the output after the array_map(<code>calc</code>,$cr) are same as follow)</p>

<pre><code>array(23) {
["batch_id"]=&gt;
string(1) "1"
["seq_id"]=&gt;
string(1) "1"
["question_id"]=&gt;
string(4) "2086"
["Item 1"]=&gt;
string(1) "1"
["Item 2"]=&gt;
string(1) "2"
["Item 3"]=&gt;
string(1) "3"
["Item 4"]=&gt;
string(1) "4"
["Item 5"]=&gt;
string(1) "5"
["Item 6"]=&gt;
NULL
</code></pre>

<p>what i need is : (minus the value of Item 1 to 6 by 1, if its null just leave it ~)</p>

<pre><code>array(23) {
["batch_id"]=&gt;
string(1) "1"
["seq_id"]=&gt;
string(1) "1"
["q_id"]=&gt;
string(4) "2086"
["Item 1"]=&gt;
string(1) "0"
["Item 2"]=&gt;
string(1) "1"
["Item 3"]=&gt;
string(1) "2"
["Item 4"]=&gt;
string(1) "3"
["Item 5"]=&gt;
string(1) "4"
["Item 6"]=&gt;
NULL
</code></pre>

<p>Finally, the result will become like this:(example of Item 1 and Item 6)</p>

<pre><code> array(4) {
["r_id"]=&gt;
string(5) "99911"
["q_id"]=&gt;
string(4) "2086"
["c_id"]=&gt;
string(6) "Item 1"
["rank"]=&gt;
string(1) "0"
}
array(4) {
["r_id"]=&gt;
string(5) "99916"
["q_id"]=&gt;
string(4) "2086"
["c_id"]=&gt;
string(6) "Item 6"
["rank"]=&gt;
string(4) NULL
}
</code></pre>
