Sorry for my title. I just don't know how to ask this. To make the story short I just need to replace a certain part of array. Let's say we have this array:
Array
(
[0] => Array
(
[restaurant_id] => 1236
[new_lat] => 76
[new_long] => 86
[date_updated] => 2013-11-15 17:20:58
)
[1] => Array
(
[restaurant_id] => 1247
[new_lat] => 6
[new_long] => 5
[date_updated] => 2013-11-15 17:20:58
)
[2] => Array
(
[restaurant_id] => 7456
[new_lat] => 21
[new_long] => 12
[date_updated] => 2013-11-15 17:20:58
)
)
Now I need to replace the index 2 with this:
Array(
[2] => Array
(
[restaurant_id] => 1236
[new_lat] => 2
[new_long] => 1
[date_updated] => 2013-11-15 17:20:58
)
)
I need to replace if I found out that there is an existing restaurant_id. If there is. Update that line. I not add the new array.
I have an idea but I don't know how to do this. My idea is:
Unserialize the array (because my array is in serialized form)
Find the target index. If found remove that index and add my new index to the bottom of array then serialize it again. If not found add only in the bottom of array and serialize.
I just dont know if I remove an index. If the index will be move automatically. Means If I delete index 2 the index 3 will became index 2 and my new array is index 3.
Ok that's all guys. thanks.
restaurant_ida unique ID for the entries?