php - pass fpassthru contents to variable -


here's portion of code (taken google charts example here http://code.google.com/apis/chart/image/docs/post_requests.html) display image chart:

 $context = stream_context_create( array('http' => array(   'method' => 'post',   'content' => http_build_query($chart)))); fpassthru(fopen($url, 'r', false, $context)); 

the problem instead of displaying image directly, i'd pass contents of fpassthru (which image) variable.. perhaps like

$image = fpassthru(fopen($url, 'r', false, $context)); 

any idea? thanks

use file_get_contents:

$image = file_get_contents($url, false, $context); 

or stream_get_contents (but don't forget close file):

$f = fopen($url, 'rb', false, $context); $image = stream_get_contents($f); fcloes($f); 

Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -