i am trying to get a some values from other site using code below
$values = file_get_contents('http://www.example.com/');
(MISSING CODE)
echo $values;
the site has only text all in first row. basically its just a text line. so i need to get 11th to 18th vale from it.
values are not in csv its values are in body tags and view source is {"token":"ABCDEFGH","expire":2345789542}
so i need abcdefgh value
If your example is correct, it's a format called JSON. Php has support for it:
$decoded = json_decode('{"token":"ABCDEFGH","expire":2345789542}');
echo $decoded->token;
outputs
ABCDEFGH
Just try to use substring on the output value like the one i ve given below
substring($values,11,7);
Do you mean that the site is returning CSV (a line of comma or tab delimited text?) If so check out str_getcsv.
An example:
$text = file_get_contents('http://www.domain.com/');
$values = str_getcsv($text);
for ($i=11; $i <= 18; $i++) {print $values[$i]."\n";}
精彩评论