Print Single Value Of Multi Dimensional Array in PHP

前端 未结 2 1004
深忆病人
深忆病人 2021-01-24 23:45

I am using following array

 Array
 (
    [0] => Array
     (
        [id] => 6
        [key] => SITE_NAME
        [value] => Webg Smarty CMS Small
           


        
相关标签:
2条回答
  • 2021-01-25 00:00

    Try this

    foreach($yourArr as $key => $value)
    {
      echo $value['value'];
    }
    

    OR

    echo $yourArr[0]['value'];  //print value of first element
    echo $yourArr[0]['key'];    //print key of first element
    
    0 讨论(0)
  • 2021-01-25 00:02
    <?php
    //$arr = your nested array aboe 
    foreach($arr as $v){
      echo $v['value']; //this will print 'Webg Smarty CMS Small' first in your example followed by '713-332-4675'
    }
    
    $arr[0]['value'] will give you 'Webg Smarty CMS Small'
    $arr[1]['value'] will give you '713-332-4675'
    
    0 讨论(0)
提交回复
热议问题