organising an array
Posted: Fri Sep 10, 2004 4:43 am
I know I'm overlooking something simple but here goes.
I have two arrays
first comes from the db and the second comes from user input.
I need to find the differences in the arrays, here comes array_diff() to the rescue, yeah. problem is it keeps the array index so you end up with
what I want is to be able to reindex the diffArray so the values restart at index 0.
Is there a built in php function of do I have to write a custom one to do it.
just trying to save some effort.
phpscott
I have two arrays
first comes from the db and the second comes from user input.
I need to find the differences in the arrays, here comes array_diff() to the rescue, yeah. problem is it keeps the array index so you end up with
Code: Select all
array from db
currentItems 0 is 1
currentItems 1 is 2
currentItems 2 is
array from user input is
itemsArray 0 is 1
itemsArray 1 is
itemsArray 2 is
array_diff() gives
diffArray 0 is
diffArray 1 is 2
diffArray 2 isIs there a built in php function of do I have to write a custom one to do it.
just trying to save some effort.
phpscott