clankill3r Posted May 2, 2012 Share Posted May 2, 2012 i have a array calles $articles, this is a part of it: Array ( [1335905082] => Array ( [channel] => [title] => SimpleXMLElement Object ( [0] => NEW PRODUCT – Blue 7-segment clock display – 0.56 digit height ) [link] => SimpleXMLElement Object ( [0] => http://www.adafruit.com/blog/2012/05/01/new-product-blue-7-segment-clock-display-0-56-digit-height/ ) [comments] => SimpleXMLElement Object ( [0] => http://www.adafruit.com/blog/2012/05/01/new-product-blue-7-segment-clock-display-0-56-digit-height/#comments ) [pubDate] => SimpleXMLElement Object ( [0] => Tue, 01 May 2012 20:44:42 +0000 ) [timestamp] => 1335905082 [description] => NEW PRODUCT – Blue 7-segment clock display – 0.56 digit height. Design a clock, timer or counter into your next project using our pretty 4-digit seven-segment display. These bright crisp displays are good for adding numeric output. Besides the four 7-segments, there are decimal points on each digit and an extra wire for colon-dots in [...] [isPermaLink] => SimpleXMLElement Object ( [0] => false ) [creator] => adafruit when i use: foreach($articles as $article) { $title = $article['title'][0]; echo '<pre>'; print_r($title); echo '</pre>'; } i get stuff like: SimpleXMLElement Object ( [0] => NEW PRODUCT – Yellow 7-segment clock display – 0.56 digit height ) SimpleXMLElement Object ( [0] => NEW PRODUCT – Dual H-Bridge Motor Driver for DC or Steppers – 600mA – L293D ) But i expected: NEW PRODUCT – Yellow 7-segment clock display – 0.56 digit height NEW PRODUCT – Dual H-Bridge Motor Driver for DC or Steppers – 600mA – L293D what do i do wrong? Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 2, 2012 Share Posted May 2, 2012 http://us.php.net/print_r http://us.php.net/echo http://us.php.net/manual/en/language.oop5.php Quote Link to comment Share on other sites More sharing options...
batwimp Posted May 2, 2012 Share Posted May 2, 2012 jesirose, you forgot foreach(). Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 2, 2012 Share Posted May 2, 2012 He already knows foreach, he used it appropriately (IMO) Quote Link to comment Share on other sites More sharing options...
clankill3r Posted May 2, 2012 Author Share Posted May 2, 2012 yeah ok with echo it goes correct but i still wonder why it goes like that? althought this fixes it (bad fix i suppose?) $title = "".$article['title'][0]; Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 2, 2012 Share Posted May 2, 2012 Why do you think it's bad? (what's wrong is the use of "". And you're using array reference instead of object. -> Edit: read too fast. What u did converts the object to a string which is probably fine for what you're doing. It could be better. Theres no way you read all 3 of those doc page that fast. The object one is what's important. Quote Link to comment 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.