redbrad0 Posted January 27, 2009 Share Posted January 27, 2009 I am using a class that returns information in a array. If I do print_r on the info that is returned it outputs the below info SimpleXMLElement Object ( [@attributes] => Array ( [status] => ok ) [message] => Add event complete [id] => E0-001-019159137-5 ) I am trying to return the value of "status" and of the "id" but this just returns a empty variable. I am sure this is something simple, but can't seem to figure out what its doing. echo "Status:" . $event['@attributes']['status'] . "<br>"; echo "ID:" . $event['id'] . "<br>"; The full code is below $ev = &new Services_Eventful(); // THE BELOW CODE WILL ADD A EVENT // ---------------------------------------------------------------------- $args = array( 'title' =>'THIS IS A TEST EVENT BY BRAD', 'start_time' => '2009-01-27 20:00:00', 'description' => 'THIS IS THE DESCRIPTION OF BRADS TEST EVENT', 'free' => '0', 'price' => '$25.00 - $35.00', 'venue_id' => 'V0-001-001450976-5' ); $event = $ev->call('events/new', $args); // ---------------------------------------------------------------------- if ( PEAR::isError($event) ) { print("An error occurred: " . $event->getMessage() . "\n"); print_r( $ev ); } else { echo "Status:" . $event['@attributes']['status'] . "<br>"; echo "ID:" . $event['id'] . "<br>"; } // The return value from a call is a SimpleXML data object. print_r( $event ); Link to comment https://forums.phpfreaks.com/topic/142710-reading-simplexmlelement-object/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.