Hi I want to format the way I output search results by showing the string query inside <em></em> tags and cut it so shows this in the middle of 20 characters.
So if i have
$text = "this is the test text i have but i dont want to output it all so just want to output the important part of the text";
$strignQuery = 'text';
So the output would be
...the test <em>text</em> i have but i... ...part of the <em>text</em>...
My thoughts so far are to string replace the 'text' with '<em>text</em>' easy then i thought if there was a way to do a split it on this with a 10 character on each way then just output the results that would work well. However i am sure there is a more elegant way of doing this.
Thanks in advance for any help
So if i have
$text = "this is the test text i have but i dont want to output it all so just want to output the important part of the text";
$strignQuery = 'text';
So the output would be
...the test <em>text</em> i have but i... ...part of the <em>text</em>...
My thoughts so far are to string replace the 'text' with '<em>text</em>' easy then i thought if there was a way to do a split it on this with a 10 character on each way then just output the results that would work well. However i am sure there is a more elegant way of doing this.
Thanks in advance for any help