dongyang9813 2016-02-01 19:23
浏览 104

在php中的foreach循环中迭代对象的对象

I have a function that is being passed an object that contains other objects that have permission ids in them. I need those permission ids in a foreach loop. Most of my tries give me an array to string conversion or a call to a non-object error.

A formatted var_dump of $permission looks like this...

array (size=1)
  0 => 
    array (size=2)
      0 => 
        object(stdClass)[9]
          public 'permission_id' => string '1' (length=1)
      1 => 
        object(stdClass)[11]
          public 'permission_id' => string '2' (length=1)

//My function starts off like this...

function checkPermission($permission) {
  $db = DB::getInstance();
  global $user;

  foreach($permission as $key=>$value){

I need to figure out how to setup that foreach loop where every round of the loop passes in that permission_id from the var_dump above.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 关于无人驾驶的航向角
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了