Jump to content

get content of array


clankill3r

Recommended Posts

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?

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.