-1
Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [billing_id] => 1
                )

            [1] => Array
                (
                    [billing_id] => 2
                )
         )
) 

how to display only billing_id from this array?

atline
  • 28,355
  • 16
  • 77
  • 113
ankur43
  • 71
  • 7

6 Answers6

2

You can use foreach in billing_id array container :

  $my_array = array(0=>array(array('billing_id'=>86),array('billing_id'=>1)));

            $i=0;
            foreach($my_array as $billingid){
                echo $billingid[$i]['billing_id'];
            $i++;}
HamzaNig
  • 1,019
  • 1
  • 10
  • 33
0

Ex. $data[1]['billing_id']; try like that.

sandip bharadva
  • 629
  • 1
  • 6
  • 19
0
echo $array_name[1]['biling_id']
darjus
  • 417
  • 3
  • 7
  • 21
0

I don't know how u make it like this but if you need only data : first[0][0]['billing_id']

HamzaNig
  • 1,019
  • 1
  • 10
  • 33
0

Try this code:

$result = array_map(function ($element) {
    return $element['billing_id'];
}, $arrayName[0]);

echo implode(', ', $result);

shorten code (without commas in result):

array_map(function ($elem) {
    echo $elem['billing_id'];
}, $arrayName[0]);
Vasyl Zhuryk
  • 1,228
  • 10
  • 23
  • @ankur43 array_map first param is callback. array_map will call function each time, you have an elements in $arrayName[0], and put this element to function. Actually you can name it by yourselfe. – Vasyl Zhuryk Jul 09 '18 at 14:22
  • @ankur43 you can change return to echo. and delete last line. it can be shorten code))) – Vasyl Zhuryk Jul 09 '18 at 14:24
0
foreach($x as $m)
        {
            for($j=0 ; $j<25;$j++){
            echo ($m[$i]['billing_id'].",");
            }
            $i++;
        }

where $x is the nameof the array

ankur43
  • 71
  • 7