Reputation: 307
I want to get the line number 17 of some text using php. My code is as:
$result = curl_exec($ch); //stores text
Now a large number of text is stored in $result & I want to get its line 17. How can I do that?
Upvotes: 2
Views: 2584
Reputation: 2193
$lines = explode("\n", $result);
echo $lines[16];
but base on your result you may have to use "\r\n" Instead of "\n"
Upvotes: 0
Reputation: 672
Find the line separator echoing the returned data from curl_exec(), then write the 17th array's element.
$res = curl_Exec($ch);
$res = explode("\n",$res);
echo $res[16]; // array starts from 0, so 16th is your 17th line.
Upvotes: 0