Reputation: 149
I'm trying to get the
['text'] value from an array object.
When I try to print_r($item), I get this as output:
ToDo Object
(
[data:private] => Array
(
[id] => 128
[user_id] => 6785
[view_stat] => 0
[position] => 12
[text] => 3rd try
[dt_added] => 2012-07-17 04:29:08
[tick] => 0
[temp_view] => 6785
[viewer] => 6785
)
)
how to get the [text] value in php?? thanks
Upvotes: 0
Views: 72
Reputation: 8020
Since those are private variables, you can't!
You need to create a public function inside the class, that will return the specific data needed:
public function getText () {
return $this -> text;
}
And outside the class you can retrieve it like this:
$class = new ToDo();
$myText = $class -> getText();
Upvotes: 4