E
E
entermix2015-04-19 23:00:47
PHP
entermix, 2015-04-19 23:00:47

How to pull out the desired array?

There is an array:

$arr =  array(
        '1' => array(
            'name' => 'example_1',
            'title' => 'example 1',
            'color' => '#90EE90'),
        '2' => array(
            'name' => 'example_2',
            'title' => 'example 2',
            'color' => '#87CEFA'),
        '3' => array(
            'name' => 'example_3',
            'title' => 'example 3',
            'color' => '#FA8072'));

Is there a standard PHP function that could return the desired array, or its index, knowing that 'name' = example_2 ?
Those. we have 'name' = example_2, we need to get the array itself, or its index
array(
            'name' => 'example_2',
            'title' => 'example 2',
            'color' => '#87CEFA')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
He11ion, 2015-04-19
@entermix

There is not. foreach or array_map/array_filter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question