简体   繁体   中英

File get contents php from another url

In short I'm using this code to get contents from another url

file_get_contents("http://www . xyz . net/data.php");

The problem I'm facing is that in the above url the data is showing up but after a huge space.
I want to say is that the above url contains a big space then the data so the process of file_get_contents is taking so much time, any suggestions to improve it ??

maybe you can get understand by this screenshot link:

Screenshot link

You can do like this:

$YOUR_DATA_STRING = file_get_contents("http://www.xyz.net/data.php");    
$string = trim($YOUR_DATA_STRING);   //trim space,newline from start and end of data
$string = str_replace(array("\r", "\n", "\t"), '', $string)  //remove newline, tab from whole data string

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM