This is how the array comes out
array(3) { [0]=> string(3) "174" [1]=> object(SimpleXMLElement)#5 (1) { [0]=> string(2) "41" } [2]=> object(SimpleXMLElement)#4 (1) { [0]=> string(2) "21" } }
I’m using this code here that generates the array.
while($row = mysql_fetch_assoc($results)){
$values[] = $row['id'];
$dom = simplexml_load_file('../data/'.$row['id'].'.xml');
foreach($dom->children() as $child)
{
$values[] = $child->views;
}
}
var_dump($values);
The xml file looks like this
<?xml version="1.0"?>
<website site_id="174" user_id="26">
<view day="23" month="10" year="11">
<views>31</views>
</view>
<view day="23" month="12" year="11">
<views>21</views>
</view>
</website>
I need to get the value of the Views into an array, but I keep getting these annoying
object(SimpleXMLElement)#5 things in the array. Also this string(3) . How do I get rid of those.
Thank you
Try to change
with
If you don’t need to see the type of the variable – just don’t use
var_dump(), butprint_r()insteadTo explain (string): This is called ‘typecasting’. Also works with other types such as (int), (bool), etc.