Welcome Guest, Not a member yet? Register   Sign In
SimpleXML
#1

[eluser]Unknown[/eluser]
Hi, I am totally new to CI, and faily new to OOP. In the past I often used this piece of code:

Code:
<?php
    $feed = simplexml_load_file('http://twitter.com/statuses/user_timeline/NAME.xml');
    sort($feed->status->id);
    foreach ($feed->status as $status)    
    {
        $name = $status->text;
        echo '<p style="color: white;">'.$name.'</p>';
    }  
    
?&gt;

I have put that into my CI view file that handles the navigation, but in Development mode it is coming up with the following NOTICE

Quote:A PHP Error was encountered
Severity: Warning

Message: sort() expects parameter 1 to be array, object given

Filename: views/01_header.php

So, what is the best way to implement this?
Please bear in mind that I am still somewhat overwhelmed by CI, so be gentle
#2

[eluser]Aken[/eluser]
The sort() function is meant for arrays, and the variable $feed->status->id is an object, not an array. You need to either put the correct array variable there if the current one is incorrect, or find out why the variable used is not an array and figure out how to make it into one.




Theme © iAndrew 2016 - Forum software by © MyBB