organising an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

organising an array

Post by phpScott »

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

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 is
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
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

Post Reply