This is probably a simple question for you php whizzes out there but I can't seem to find an answer in google! I have a multi-dimensional array which first set of keys are named and I want to change them into numbers like 0, 1, 2.. If it was a normal array I could set $newArray = array_values($multiArr); and it would get rid of the keys and make them numeric! But since its multidimensional theres another set of keys/values underneath this. Could I somehow use a loop to loop through it and define each one? But then how would I specify the current key? Any advice would help thank you! If this helps at all the data coming in is a JSON received from a device and there's something wrong with the encoding so the data looks like this: `Array ( [�w� ��߯19�] => Array ( [down] => 1279146141431 [up] => 1279146351453 ) ` So I need to somehow get access to the data underneath each crazy key. asked Jul 15, 2010 at 21:56
Doug MolineuxDoug Molineux 12.1k25 gold badges89 silver badges142 bronze badges This code:
yields $arr2 in this form:
Isn't that what you're trying to get? answered Jul 15, 2010 at 22:03
JavadocMDJavadocMD 4,3272 gold badges25 silver badges23 bronze badges 4 A little recursion does the trick
answered Jul 15, 2010 at 22:13
Peter BaileyPeter Bailey 104k31 gold badges181 silver badges201 bronze badges 2 I didn't entirely understand the structure of your array, but you can iterate through a multidimensional associative array in a number of ways. Here's one that builds a numerically indexed array:
answered Jul 15, 2010 at 22:03
sunetossunetos 3,3881 gold badge22 silver badges14 bronze badges
answered Mar 21, 2019 at 14:53
1 |