I have the following code:
<?php
$attr_data = array();
foreach ($content->search as $attributeSelected)
{
$attr_data[] = $attributeSelected['id'];
}
?>
This saves the data as:
Array (
[0] => SimpleXMLElement Object ( [0] => 23914175_laptop )
[1] => SimpleXMLElement Object ( [0] => 23914175_laptop )
[2] => SimpleXMLElement Object ( [0] => price_range_10_50004 )
)
However I just want the array data and not to include the "SimpleXMLElement Object". So I added the following code:
<?php
$attr_data = array();
foreach ($content->search as $attributeSelected)
{
$attr_data[] = json_decode(json_encode($attributeSelected['id']), true);
}
?>
Which now gives me the data as:
Array (
[0] => Array ( [0] => 23914175_laptop )
[1] => Array ( [0] => 23914175_laptop )
[2] => Array ( [0] => price_range_10_50004 )
)
I'm not sure what I'm doing wrong. I just want to save the data to an array and then use an If statement to check if the array contains specific data.