I parse an XML file with PHP. My problem is I have a dynamic string with multiple lines and each line has no space char on it, and I want to find a word on that string. String’s length is dynamic so it changes every time.
Since strings length is dynamic I can’t use something like $c = substr($string, 0, -1) or I can’t use something like $i=stripos($story," word"); because there is no space in the string.
example string is 4 lines and I want to detect the word ARC.docx on second line before </a>:
<![CDATA[
In <a href='/home/Apps/ARCMeeting'>ARCMeeting</a>, You edited the file <a href='https://dropbox.com/get/Apps/ARCMeeting/ARC.docx?w=d3' title='/Apps/ARCMeeting/ARC.docx'>ARC.docx</a>.
<br/>
]]>
My goal is add that ARC.docx on second line before </a> to a message body
$message='X File has been edited!';
so I can print
$message='ARC.docx File has been edited!';
How can I detect word that in between .......>exampleword</a>. in above string?
Thanks in advance
You can try preg_match function.
In your case it will look something like: