I jus’t can’t wrap my head around this. What I’m missing is the logical bit.
I have this $myArray :
array(3) {
[0]=>
array(2) {
["lang"]=>
string(4) "en"
["url"]=>
string(42) "http://feeds.feedburner.com/wordpress/haJM"
}
[1]=>
array(2) {
["lang"]=>
string(4) "en"
["url"]=>
string(37) "http://feeds.feedburner.com/hackaday/LgoM"
}
[2]=>
array(2) {
["lang"]=>
string(4) "klingon"
["url"]=>
string(36) "http://www.maitre-eolas.fr/feed/atom"
}
}
So one array of unknown size, and each element is an array of know size, (2 key / value pairs (lang = something & url = something) the whole point is not knowing what lang is. It can really be any (alphanumerical) value.
And what I’d like to do is to build a new, clean array where keys are sorted by their name, like this :
array(2) {
[0]=>
array(2) {
["lang"]=>
string(2) "en"
["urls"]=>
array(2) {
string(42) "http://feeds.feedburner.com/wordpress/haJM"
string(37) "http://feeds.feedburner.com/hackaday/LgoM"
}
}
[1]=>
array(2) {
["lang"]=>
string(6) "klingon"
["urls"]=>
array(1) {
string(36) "http://www.maitre-eolas.fr/feed/atom"
}
}
}
But when I try to put the first $myArray[0][‘lang’] in a variable and compare it with the following, it… Works. Once. And stops.
I’m doing it wrong, I know it.
Try this:
That would give you:
Do you really need the format listed above? Or will this do as well?