sublevel4 Posted September 12, 2012 Share Posted September 12, 2012 I have the following code foreach($response['body']->project as $project){ // output only where status is active if ($project->status == 'active'){ $created = $project->{'created-on'}.','; $catagory = $project->company->name.','; $project = $project->name; $projectNumber = $project->id . '<br>'; echo $projectNumber; $data_string .= $created . $catagory . $project. "\n"; } } if i print the array i get [body] => SimpleXMLElement Object ( [@attributes] => Array ( [type] => array ) [project] => Array ( [0] => SimpleXMLElement Object ( [created-on] => 2009-11-30 [id] => 4038672 [last-changed-on] => 2009-12-21T21:02:37Z [name] => Reusable bags [status] => archived [company] => SimpleXMLElement Object ( [id] => 1621970 [name] => Marketing ) ) $project comes back as Reusable bags $created comes back as 2009-11-30 $catagory comes back as marketing My problem is that $projectNumber comes back blank. Is there something wrong with my code that would cause this? How can i access all of other items but that one. Any help is appreciated. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/268295-array-item-not-showing-up/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 12, 2012 Share Posted September 12, 2012 $project = $project->name; ^^^ That line of code is overwriting the $project object with the name, so after that point $project->id doesn't exist. Quote Link to comment https://forums.phpfreaks.com/topic/268295-array-item-not-showing-up/#findComment-1377291 Share on other sites More sharing options...
sublevel4 Posted September 12, 2012 Author Share Posted September 12, 2012 DOH!! Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/268295-array-item-not-showing-up/#findComment-1377304 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.