Answer the question
In order to leave comments, you need to log in
How to get id from array key?
Hello. There is an array $result
print_r($result) returns:
Array
(
[id:33002, date] => 26.08.2020 17:21:30
[to] => 123
[out] => 321
[status] => 1
)
Answer the question
In order to leave comments, you need to log in
The question is probably how to get the key? Because in your case, you can get an identifier from a similar string in any convenient way:
$id = null;
reset($array); // надежнее обнаружить нужный ключ перебором и последующей проверкой
$key = key($array);
$match = null;
if ( preg_match('/^id:(\d+)/', $key, $match) ) $id = (int) $match[1];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question