My code to delete key like this :
<?php
$photoList = array(
array(
'id' => 1,
'name' => 'chelsea.jpg'
),
array(
'id' => 2,
'name' => 'mu.jpg'
),
array(
'id' => 3,
'name' => 'city.jpg'
)
);
if(count($photoList) > 1) {
$id = 1;
foreach($photoList as $key => $value) {
if($value['id'] == $id)
unset($photoList[$key]);
}
}
echo '<pre>';print_r($photoList);echo '</pre>';
?>
If the code executed, the result like this :
Array
(
[1] => Array
(
[id] => 2
[name] => mu.jpg
)
[2] => Array
(
[id] => 3
[name] => city.jpg
)
)
I want the value re-update. So id start from 1 and the key start from 0 like this :
Array
(
[0] => Array
(
[id] => 1
[name] => mu.jpg
)
[1] => Array
(
[id] => 2
[name] => city.jpg
)
)
How can I do it? Please help me, what is wrong? thanks