/ Published in: PHP
converts array (which is reference) in format
<code>
array(0 => array('id' => 1, 'name' => 'orange'), 1 => array('id' => 3, 'name' => 'banana'));
</code>
to
<code>
array(1 => array('id' => 1, 'name' => 'orange'), 3 => array('id' => 3, 'name' => 'banana'));
</code>
<code>
array(0 => array('id' => 1, 'name' => 'orange'), 1 => array('id' => 3, 'name' => 'banana'));
</code>
to
<code>
array(1 => array('id' => 1, 'name' => 'orange'), 3 => array('id' => 3, 'name' => 'banana'));
</code>
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public function make_assoc(&$arr, $key = 'id') { $tmp = $arr; for ($a = 0;$a<$max;$a++) { $kold[] = $a; $knew[] = $tmp[$a][$key]; $arr[$tmp[$a][$key]] = $tmp[$a]; } }