douhan5853 2016-08-25 11:14
浏览 55
已采纳

如何从控制台访问数组的主题

I Can print Object/Arrays from php into Console and than access its sub objects.

For example I've some array in php

<?php 
    $arr = Array('name'=>'sajjad','age'=>'20','sex'=>'m');
    $json = json_encode($arr);
?>
<script>
    console.log(<?php echo $json; ?>);
</script>

I will get following lines as object in chrome console.log.

Object {name: "sajjad", age: "20", sex: "m"}

Suppose i'm not working on backend, how can i access to the subobjects of this object in chrome console panel. like..

For example if I type

>object.name

( and hit enter , console should return me)
>sajjad

or If I type in console

   >object.age
   >20

or

   >object.sex
   >m

Thanks ... For understanding. please see pic one. what i want. enter image description here

  • 写回答

2条回答 默认 最新

  • dtpw54085 2016-08-25 13:34
    关注

    I've found the solution. I searched but couldn't find. But a little hit and try helped.

    Problem:

    enter image description here

    Solution 1.

    enter image description here

    2.

    enter image description here

    3.

    enter image description here

    I hope somebody else do need this solution. :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度