|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Any way to reindex the php array?
hi guys
i am just looking for any simple php function or any inbuilt php function which reindex the php keys of an array? for example, I have an array PHP Code:
I want to make the keys of all element in sequence so the output should look something like PHP Code:
|
|
#2
|
|||
|
|||
|
array_merge() will re-index an array with numeric values or sort() if you don't mind changing the order of the items to alphabetical/numerical order.
|
|
#3
|
|||
|
|||
|
Quote:
Thanks for the reply but array merge required two array. here in my case i have only one array and want to re-index the key. |
|
#4
|
||||
|
||||
|
amber.long83--
No, array_merge WILL accept 1 parameter. When you use array_merge, PHP internally creates an empty array to start and then merges the elements of the arrays provided to array_merge. If only one array is given, then that's all there is to merge into the empty array. However, probably the easiest and most intuitive way to do what you're looking for is to use array_values.
__________________
www.saltcitytech.com Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth Remember kids, it's mysql_real_escape_string, not mysql_fake_escape_string. Last edited by bluephoenix : March 21st, 2009 at 04:55 PM. |
|
#5
|
|||
|
|||
|
thanks man
thanks bluephoenix
array_values is the trick for my requiredment thanks again Quote:
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Applications > Any way to reindex the php array? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|