Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
XML
foreach($catgory as $key=>$value)
     {
        foreach($value as $catname=>$catvalue)
        {
            echo ($catvalue['title'])."<br/>";
        }
     }


Message: Illegal string offset 'title'



when i dump $value it gives the following

VB
object(stdClass)#22 (13) {
  ["id"]=>
  string(1) "3"
  ["title"]=>
  string(9) "Project 1"
  ["user_id"]=>
  string(1) "2"
  ["description"]=>
  string(31) "<p>
    Project 1 Description</p>
"
  ["keywords"]=>
  string(20) "fsdfsd fd sfd sd d d"
  ["category_id"]=>
  string(1) "1"
  ["type"]=>
  string(5) "fixed"
  ["budget_min"]=>
  string(10) "4294967295"
  ["budget_max"]=>
  string(10) "4294967295"
  ["created_at"]=>
  string(19) "2014-01-27 19:05:16"
  ["updated_at"]=>
  string(19) "2014-01-29 17:20:01"
  ["file"]=>
  string(0) ""
  ["status"]=>
  string(7) "pending"
}




the question is how to get title only ??
Posted
Updated 29-Jan-14 11:25am
v2
Comments
Sergey Alexandrovich Kryukov 29-Jan-14 14:53pm    
And the question is..?
—SA

1 solution

It a syntax error you have here...
$catvalue is holds the value part from $value (where $catname has the key).
You try to read $catvalue as it was an array of some properties, but it turns out that it's a string, so PHP engine try to interpret 'title' as a character index, but that impossible...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900