I'm writing some parcer. And I need to get the position of specified text. I can get it, but it's uncorrect at all. Please see the code and advice, why do I have such problem. Thanks
<?php
$string = '
<tbody>
<tr>
<td width="150" rowspan="2" > <a
href="https://www.olx.ua/d/obyavlenie/ssd-apacer-panther-240-ssd-a5340-IDNjkB7.html?sd=1#8e82a1086f;promoted"
title=""> <img src="https://ireland.apollo.olxcdn.com:443/v1/files/wbikewxnjblg1-UA/image;s=644x461" alt="SSD apacer panther 240 ssd, a5340.">
<span title="ТОП"></span>
<span > <i data-icon="delivery"></i> </span>
</a> </td>
<td valign="top" >
<div >
<h3 > <a
href="https://www.olx.ua/d/obyavlenie/ssd-apacer-panther-240-ssd-a5340-IDNjkB7.html?sd=1#8e82a1086f;promoted"
data-cy="listing-ad-title">
<strong>SSD apacer panther 240 ssd, a5340.</strong>
</a> </h3>
<p >
<small > Компьютеры и комплектующие » Комплектующие и аксессуары </small>
</p>
</div>
</td>
<td width="200"
valign="top">
<div >
<p > <strong>700 грн.</strong> </p>
</div>
</td>
</tr>
<tr>
<td valign="bottom" >';
$needle = '<p >';
$string = preg_replace('#\t#', '', $string);
echo $string;
$pos = strpos($string, $needle);
var_dump($pos);
CodePudding user response:
The result is correct:
When i copy past the result of echo $string;
in notepad , and when i search for the neddle, it is at pos 3112 (it take into account each space)
What is the result you have and what is the result you expect?
CodePudding user response:
Yes, sorry, U're right, I was used a little another code and found my problem. Thanks for answering me.