I want to output the third element from the same HTML element. I know how to output a div
or span
with an id or a class but I have no idea how to output a same HTML element. I thought it was something with p[1]
but it doesn't work.
I know there is a lot of answered questions about it but it never explained how to output the same HTML element without a class
or id
.
website : http://localhost/
<p>example</p>
<p>example1</p> <!-- i want to take this one -->
<p>example2</p>
-------------------
php script :
<?php $curl = curl_init('http://localhost/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$code3 = curl_exec($curl);
curl_close($curl);
$code = '/<p>(.*?)<\/p>/s';
$code6= preg_match($code, $code3, $code4);
echo $code4[1]
?>
/* doesn't work ..
also php.net doesnt give a good example about it so i hope someone can help me here.
thanks advanced !
*/