How to choose the object



  • There are objects that are stored in $lt-stateimages; if so var_dump($lt->images); I get it.

    [0]=>   object(Image) {
        ["id"]=>       int(15)          
        ["for_home"]=>       int(1)     }     
    [1]=>   object(Image){    
        ["id"]=>       int(1693)           
        ["for_home"]=>       NULL     } 
    [2]=>   object(Image) {     
        ["id"]=>       int(1694)         
        ["for_home"]=>       NULL    }  
    [3]=>   object(Image) {     
        ["id"]=>       int(1695)                
        ["for_home"]=>       NULL     }     
    [4]=>   object(Image){           
        ["id"]=>       int(1696)               
        ["for_home"]=>       NULL     } 
    

    I'm trying to get an object that's for.

    foreach($lt->images as $image); 
         if($image->for_home==1) {
           echo('yes');
        }
    

    And of course I don't get anything to explain how to get an object that's got for *home=1



  • foreach somehow. foreach($lt->images as $image); starting ;instead {

    $lt = (object) array('images' => array(
        (object) array('id' => 15, 'for_home' => 1),
        (object) array('id' => 1693, 'for_home' => NULL),
        (object) array('id' => 1694, 'for_home' => NULL),
        (object) array('id' => 1695, 'for_home' => NULL),
        (object) array('id' => 1696, 'for_home' => NULL),
    ));
    

    foreach($lt->images as $image) {
    if($image->for_home == 1) {
    echo('yes');
    }
    }


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2