Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
<code lang="php"> Array ( [661] => Array ( [w_id] => 30557 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190616 ) [662] => Array ( [w_id] => 30556 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190616 ) [663] => Array ( [w_id] => 30555 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190616 ) [664] => Array ( [w_id] => 30560 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190617 ) [665] => Array ( [w_id] => 30558 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190617 ) [666] => Array ( [w_id] => 30559 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190617 ) [667] => Array ( [w_id] => 30561 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190618 ) [668] => Array ( [w_id] => 30562 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190618 ) [669] => Array ( [w_id] => 30564 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190618 ) [670] => Array ( [w_id] => 30563 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190618 ) [671] => Array ( [w_id] => 30675 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190622 ) [672] => Array ( [w_id] => 30676 [up] => 3580 [name_t] => Водолазка женская [name_g] => KTL 190622 ) ) </code>
$sku= 'KTL 190617'; $keys = array_keys(array_filter( $goods, function ($goody) use ($sku) { return $goody['name_g'] == $sku; } ));
function filter_by_value($array, $index, $value){ if (is_array($array) && count($array) > 0) { foreach(array_keys($array) as $key){ if (isset($array[$key][$index])) { $temp[$key] = $array[$key][$index]; if ($temp[$key] == $value){ $newarray[] = $key; } } } } return $newarray; } $keys = filter_by_value($trik, 'name_g', $t['name_g']);
array_column($array, 'name_g', 'w_id');
$keys = []; $searchFor = 'KTL 190616'; foreach ($array as $key => $item) { if($searchFor === $item['name_g']) { $keys[] = $key; } } print_r($keys);
function filter_by_value ($array, $index, $value){ if(is_array($array) && count($array)>0) { foreach(array_keys($array) as $key){ $temp[$key] = $array[$key][$index]; if ($temp[$key] == $value){ $newarray[$key] = $array[$key]; } } } return $newarray; } $results = array( 0 => array('key1' => '1', 'key2' => 2, 'key3' => 3), 1 => array('key1' => '12', 'key2' => 22, 'key3' => 32) ); $nResults = filter_by_value($results, 'key2', '2');