【问题标题】:how to get data from array in the table in separate variable如何从单独变量中的表中的数组中获取数据
【发布时间】:2014-12-11 11:09:17
【问题描述】:

这是我转储数组时的输出。我想要单个变量中的每个值。任何人都可以以表格形式提供帮助吗?它应该显示所有域,如 new.com(显示所有域)。

{
"Google-Yahoo": {
    "com": "available",
    "net": "notavailable"
     "org": "notavailable"
},
"GoogleSite": {
    "com": "available",
    "net": "notavailable"
    "org": "notavailable"
},
"Deal-Seek": {
    "com": "available",
    "net": "notavailable"
    "org": "notavailable"
},
"Love-Seek": {
    "com": "available",
    "net": "available"
    "org": "notavailable"
},
"True-Seek": {
    "com": "available",
    "net": "available"
   "org": "notavailable"
}
}

【问题讨论】:

  • 我试过foreach($details as $domain){ echo $domain['com']."</br>"; echo $domain['net']."</br>"; echo $domain['org']."</br>"; foreach($domain as $new_array){ //echo $new_array; } }
  • 不是数组,是里面有对象的对象。即使您可以使用 foreach php.net/manual/es/language.oop5.iterations.php 使用 key=>value

标签: php arrays codeigniter


【解决方案1】:

使用对象表示法而不是数组表示法。

foreach($details as $domain){ 
    echo $domain->com."</br>"; 
    echo $domain->net."</br>"; 
    echo $domain->org."</br>"; 
    etc...

你的结果不是一个数组,它是一个对象。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-29
    • 2019-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多