<?php
$ar[0] = Array ( 'type' => 101, 'width' => 540, 'height' => 960, 'url' => 'https://a.com');
$ar[1] = Array ( 'type' => 102, 'width' => 340, 'height' => 604, 'url' => 'https://b.com');
$ar[2] = Array ( 'type' => 103, 'width' => 240, 'height' => 430, 'url' => 'https://c.com');
$ar[3] = Array ( 'type' => 104, 'width' => 240, 'height' => 420, 'url' => 'https://d.com');
$type = 102;
$indd = '';
foreach($ar as $ind=>$arr){
if ($arr['type'] == $type) {
$indd = $ind;
break;
}
}
if($indd){
echo $ar[$indd]['width'].PHP_EOL;
echo $ar[$indd]['height'].PHP_EOL;
echo $ar[$indd]['url'].PHP_EOL.PHP_EOL;
}
function arrayByType($arra, $type){
$indd = '';
foreach($arra as $ind=>$arr){
if ($arr['type'] == $type) {
$indd = $ind;
break;
}
}
if($indd){
return $arra[$indd];
}
}
print_r(arrayByType($ar, $type));
- Output for 7.1.26 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- 340
604
https://b.com
Array
(
[type] => 102
[width] => 340
[height] => 604
[url] => https://b.com
)
preferences:
136.16 ms | 408 KiB | 5 Q