This question already has answers here:
Special characters in property name of object
(2 answers)
Closed 9 years ago.
When I do a print_r($this->info->artist->image[4]);, I get this:
stdClass Object
(
[#text] => http://userserve-ak.last.fm/serve/_/68145708/AWOLNATION+PNG.png
[size] => mega
)
How do I get the [#text] part?
You would do:
$this->info->artist->image[4]->{'#text'};
$this->info->artist->image[4]->{'#text'};
Related
This question already has answers here:
How to remove duplicate values from an array in PHP
(26 answers)
Closed 3 years ago.
I have an array,
`Array
(
[0] => 2019-08-02
[1] => 2019-08-02
[2] => 2019-08-03
)`
I need to remove duplicates from this array.I tried converting strtotime and compared But not getting result.
Please help
Regards,
Rekha
You can just write the code like this:
$arr = array_unique($arr)
Hope this helps.
This question already has answers here:
Get values stdClass Object PHP
(1 answer)
How to extract and access data from JSON with PHP?
(1 answer)
Closed 6 years ago.
If I have a array formatted as below
[
{
'id':1,
'some_int': 3,
'foo':'bar'
}
]
How can I retrieve, for example, 'bar' value?
If I write
$array[0]['bar']
It throws Cannot use object of type stdClass as array
If I write
$array['bar']
It throws Unidentified index: bar
This question already has answers here:
How can I access an array/object?
(6 answers)
Closed 6 years ago.
I have an array that holds a number of arrays. I access them in turn e.g.
print_r($orderData[0]) and the output is:
Array (
[201] => Array (
[name] => SuperMarket One
[type] => line_item
[item_meta] => Array (
[_qty] => Array (
[0] => 1
)
)
)
)
My issue is, I can't seem to access anything e.g. print_r($orderData[0]['name']) gives me:
Notice: Undefined index: name in /Path
Likewise, I can't use print_r($orderData[0][0]) etc.
I must be missing something quite obvious here.
You have another array in it with the key 201. Use PHP's function var_dump($orderData[0]) to view the complete structure of your array.
Access it using
$orderData[0][201]['name']
This question already has answers here:
How can I access an array/object?
(6 answers)
Closed 6 years ago.
can i ask ? . I have class cURL POST into a website ( API Integration ) , and if i post with class. The result is (i use print_r) :
stdClass Object
(
[order] => 200029
)
1
How to grab [order] value?
You can use:
$yourVar->order;
This question already has answers here:
What is the difference between public, private, and protected?
(16 answers)
Closed 9 years ago.
I used the code below to get the object's property _items:protected, but no luck.
$obj = JSite::getMenu();
print_r($obj->_items:protected);
Object output
JMenuSite Object
(
[_items:protected] => Array
(
[101] => stdClass Object
(
[id] => 101
[menutype] => mainmenu
Anyone know what wrong with my code? Thanks.
You are trying to access a protected property from outside the class.
A protected property can only be accessed from within the class itself or classes that inherit from that class.
Read up on OOP access modifiers.