I want to select the values from the last key array.
I have this array:
Array
(
[01] => Array
(
[cat_id] => 15
[offset] => 4951
)
[02] => Array
(
[cat_id] => 15
[offset] => 4251
)
[03] => Array
(
[cat_id] => 15
[offset] => 4001
)
)
To get the last key here is my code:
end($completed_steps);
$lastKey = key($completed_steps);
But how can I get the values of the last key? Like, I want to get cat_id
and offset
.
(sorry for late response, here's an additional note, I had to confirm this first from someone.)
NOTE : I want to store those values as variables. I think I have the idea now.
Result of end()
is the last value in array:
$values = end($completed_steps);
print_r($values);
Use below code for fetching the values of the last key in array :-
$lastValue = end($completed_steps);
$cat_id = $lastValue['cat_id']);
$offset = $lastValue['offset']);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.