Is it possible to pass file_get_contents() data to another functions? See below for a better understanding.
function getURL($search){
$url = "http://www.example.com?search=".$search;
$data = file_get_contents($url);
$formated = formatData($data);
return $formated;
}
function formatData($data){
$format = $data;
//some formating here
return $format;
}
This is the kind of thing I am trying to do as currently, if I want to do this, I have to call the file_get_contents() function again, but this slows down the application as it’s making a call to the same site twice.
Any help would be nice
file_get_contents() returns a string (http://php.net/manual/en/function.file-get-contents.php). You can pass the string to another function (just like in your example). Is that not working?