how to get some of values from multidimensional array

Async

Using the array below, I want to get just some value of an element containing a certain value for option_name. For example, I want to get the element with option_name => custom_radio_gender then the result will show the value of option_value for that element (i.e. Radio 1).

Array
(
    [0] => Array
        (
            [ID] => 15
            [user_id] => 3
            [option_name] => custom_monStart
            [option_value] => a:3:{i:0;s:8:"05:30 am";i:1;s:8:"07:30 am";i:2;s:8:"09:30 am";}
            [autoload] => yes
        )

    [1] => Array
        (
            [ID] => 13
            [user_id] => 3
            [option_name] => custom_radio_gender
            [option_value] => Radio 1
            [autoload] => yes
        )

    [2] => Array
        (
            [ID] => 14
            [user_id] => 3
            [option_name] => custom_time2
            [option_value] => 
            [autoload] => yes
        )
)
Does

It's a basic PHP question,which has nothing relationship with javascript.What you need is just a function like:

function getValue($array, $key){
    foreach($array as $content){
        if(array_key_exists("option_name", $content) && $content["option_name"] == $key){
            return $content["option_value"];
        }
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to get the highest and lowest Values and sum from Multidimensional array in PHP

How to get rid of duplicate values from multidimensional array

How to get all values of one key from laravel multidimensional array

How to get indexes of k maximum values from a numpy multidimensional array

How to get values from multidimensional array, searching by name?

PHP, Smarty, how to get values from multidimensional array

How to get rid of keys and values ​while leaving some keys and values ​in a multidimensional array

Get values from multidimensional array PhP

get values from keys with foreach (multidimensional array)

How to extract values from multidimensional array grouped by some value inside it using PHP?

Create new array from a multidimensional if some values are similar in php?

How to sum same values from multidimensional array?

How to remove duplicate values from a multidimensional array?

how to output values from multidimensional array

get array of array values from multidimensional array on PHP

Javascript get values from multidimensional array object by other values

Get Array of Multiple Maximum Key vs Values from a multidimensional array

Get an array from a multidimensional array between two values

Array Map multidimensional, get values from 3 array Java

How to get a value from listview with multidimensional array?

How to get multidimensional array from JSON in Typescript?

How to get common values from 4 multidimensional arrays using array_intersect

How to get one value from duplicates values in Multidimensional array using PHP?

how to add multidimensional array values ​whose values ​are from different arrays

Get specific values from randomized multidimensional array with url key

How to build the keys of a multidimensional array in PHP from the values of another array?

How to sum values from a python multidimensional array based on an element in the array?

how to get some values of an array php

Extracting values from multidimensional array