I'm trying to find and output the value from a specific key.
$name = 'G';
$ids = array();
foreach($arrayChart as $key){
$foundAtPosition = strpos($key['Name'], $name);
if ($foundAtPosition === false ||
$foundAtPosition > 0) {
continue;
}
$ids[] = $key['ID'];
}
echo join(',', $ids) . "\n";
Here is the array
$arrayChart = array(
array(
"Name" => "Mike G",
"ID" => "0001234",
"Hours" => 38
),
array(
"Name" => "Mike L",
"ID" => "0005678",
"Hours" => 42
)
array(
"Name" => "John G",
"ID" => "0003615",
"Hours" => 42
)
);
This code above was provided by @zedfoxus He helped me with a previous problem.
I want to find the ID number from the key value ID by using the last name letter "G" from key Name. I want to output them in the same line. The problem with the above function is that it doesn't print anything.