dourou9477 2017-06-07 08:53
浏览 43
已采纳

如何从模态数据中获取特定值

I am getting value from modal which contains array as well like this:

      <?php var_dump( $myaccount);?>

Result:

array (size=1) 0 => object(stdClass)[28]

public 'daysselected' => string '["Monday","Tuesday"]'

public 'due' => string '["2017-06-12","2017-06-13"]'

I am trying to access Monday as single and similarly the date. How can i do so?

I am trying this:

 if(!empty($myaccount)){
     foreach($myaccount as $it){
           echo $it->daysselected[0];//i get '[' only
      }
}
  • 写回答

3条回答 默认 最新

  • duan39779 2017-06-07 09:00
    关注
    if(!empty($myaccount)){
      foreach($myaccount as $it){
        $days = str_replace(['\'', '"', '[', ']'],'', $it->daysselected );
        $daysSelected = explode(',', $days);
        echo $daysSelected[0];
      }
    }
    

    try to use this. But error is somewhere in getting of this value.

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

报告相同问题?