Get first element in PHP stdObject

后端 未结 7 1122
日久生厌
日久生厌 2020-12-05 09:23

I have an object (stored as $videos) that looks like this

object(stdClass)#19 (3) {
  [0]=>
  object(stdClass)#20 (22) {
    [\"id\"]=>
    string(1) \         


        
相关标签:
7条回答
  • 2020-12-05 10:07

    You could loop on the object maybe and break in the first loop... Something like

    foreach($obj as $prop) {
       $first_prop = $prop;
       break; // exits the foreach loop
    } 
    
    0 讨论(0)
提交回复
热议问题