Reputation: 144
I want to change last child of array (122) with second child of array (0). You can see with samples. Please help me.
Current version:
Array
(
[0] => Array
(
[122] => Array
(
[PROGRAM_ID] => 181
[VENUE_ID] => 2
[AUDIT_ID] => 96
)
)
)
I want this:
Array
(
[122] => Array
(
[PROGRAM_ID] => 181
[VENUE_ID] => 2
[AUDIT_ID] => 96
)
)
Upvotes: 2
Views: 8241
Reputation: 557
This works fine $array = reset($array);
for the first child and $array = end($array);
for the last.
Upvotes: 2
Reputation: 3457
I suppose you're looking for something like this....
https://stackoverflow.com/a/2408971/1172872
Like this:
$result = array();
foreach($array as $inner) {
$result[key($inner)] = current($inner);
}
The $result
array would now look like this:
Array
(
[122] => Array
(
[PROGRAM_ID] => 181
[VENUE_ID] => 2
[AUDIT_ID] => 96
)
)
Upvotes: 0