Return rows from a multidimensional array with same value in php -



Return rows from a multidimensional array with same value in php -

i have multidimensional array , need filter specific rows.

here's contents of sample array.

$arr = array( array("id"=>1, "msisdn"=>10, "sc"=>8155), array("id"=>2, "msisdn"=>20, "sc"=>22020), array("id"=>3, "msisdn"=>10, "sc"=>8155), array("id"=>4, "msisdn"=>10, "sc"=>8155), array("id"=>5, "msisdn"=>20, "sc"=>22020), array("id"=>6, "msisdn"=>30, "sc"=>22020) );

how can rows value of msisdn equal 10, example?

something this? iterate through array , can search specific value , type.

i don't want go much detail question isn't exclusively clear.

function get_rows_by_type($array, $type, $val) { $output = array(); foreach ($array $a) { if ($a[$type] === $val) { $output[] = $a; } } homecoming $output; } var_dump (get_rows_by_type($arr, 'msisdn', 10));

php arrays

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -