Reputation: 23
Please can someone tell me what I am doing wrong? I am trying to retrieve all the data in the array below in PHP and I am having problems doing this. Here is the example:
<?php
$url = 'http://www.example.com/';
if (!$fp = fopen($url, 'r')) {
trigger_error("Unable to open URL ($url)", E_USER_ERROR);
}
$meta = stream_get_meta_data($fp);
print_r($meta);
foreach($meta as $key=>$value) {
echo '<br>'.$value;
}
fclose($fp);
?>
The foreach loop above permit me to loop through and retrieve all the data in the array, but my questions are:
[wrapper_type]
and other
values independently?[wrapper_data] => Array
without retrieving all the values together?Upvotes: 0
Views: 90
Reputation: 255
just use 'wrapper_type' index in your array($meta).
$type = $meta["wrapper_type"];
echo $type;
Upvotes: -1
Reputation: 36924
How can I retrieve only the value http of [wrapper_type]
Just with $meta['wrapper_data']
How can I retrieve only one value of [wrapper_data]
The same, Array elements can be accessed using the array[key] syntax: $meta['wrapper_data'][0]
, $meta['wrapper_data'][1]
, ...
Upvotes: 2
Reputation: 42676
This is pretty basic stuff; you may want to do some reading up on PHP basics before progressing further. Nevertheless...
How can I retrieve only the value http of [wrapper_type] and other values independently?
$type = $meta["wrapper_type"];
echo $type;
How can I retrieve only one value of [wrapper_data] => Array without retrieving all the values together?
$the_fourth_header = $meta["wrapper_data"][4];
echo $the_fourth_header;
Upvotes: 2