Answer the question
In order to leave comments, you need to log in
How to find in an array by a numeric key, if all the keys are string?
array(
"mandarin" => "frukt",
"gopota" => "ovoch"
);
Answer the question
In order to leave comments, you need to log in
as an option - a function
$myArr = array(
"mandarin" => "frukt",
"gopota" => "ovoch"
);
function searchByKey($array, $num) {
$i = 0;
foreach($array as $item) {
if($i === $num) return $item;
$i++;
}
}
echo serachByKey($myArr, 1); // => ovoch
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question