I am trying to extract the subject line with the returned array $ matches from preg_match_all (). Let me start with an example:
preg_match_all("/(.)/", "abc", $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
This will return:
Array ( [0] => Array ( [0] => Array ( [0] => a [1] => 0 ) [1] => Array ( [0] => a [1] => 0 ) ) [1] => Array ( [0] => Array ( [0] => b [1] => 1 ) [1] => Array ( [0] => b [1] => 1 ) ) [2] => Array ( [0] => Array ( [0] => c [1] => 2 ) [1] => Array ( [0] => c [1] => 2 ) ) )
In this case, I want to highlight the total consumed data and each backlink.
The result should look like this:
<span class="match0"> <span class="match1">a</span> </span> <span class="match0"> <span class="match1">b</span> </span> <span class="match0"> <span class="match1">c</span> </span>
Another example:
preg_match_all("/(abc)/", "abc", $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
Must return:
<span class="match0"><span class="match1">abc</span></span>
Hope this is clear enough.
I want to highlight the total consumed data and highlight each backlink.
Thanks in advance. If something is unclear, please ask.
Note. It should not interrupt html. The regex string is AND and is unknown by code and is completely dynamic . Thus, the search string can be html, and the matched data can contain html-like text, and what not.