How can I extract full words from a long string sentence
Posted: Tue Oct 11, 2005 2:13 pm
Hi All
I am currently extracting information from a database which is a string. What I need to do is extract a few words from the sentence. I currently have 26 characters I can extract from the string that are allowed to go in a html table (first row) then I must put in a html break (<br>) and insert the second 26 characters on a second row from where I left off on the first line. The problem with this is that words get cut off I want whole words to go in the first and second lines. How can I do this?
Currently I am using the code
RESULT which i dont want as word get cut
Hello this is a long strin
g item that i am inserting
Many thanks php gurus
Antek
I am currently extracting information from a database which is a string. What I need to do is extract a few words from the sentence. I currently have 26 characters I can extract from the string that are allowed to go in a html table (first row) then I must put in a html break (<br>) and insert the second 26 characters on a second row from where I left off on the first line. The problem with this is that words get cut off I want whole words to go in the first and second lines. How can I do this?
Currently I am using the code
Code: Select all
$news = "Hello this is a long string item that i am inserting in a web page"
for the first line of text
substr($news, 0, 26)
I break (<br>)
for the second line of text
substr($news1, 26, 52)RESULT which i dont want as word get cut
Hello this is a long strin
g item that i am inserting
Many thanks php gurus
Antek