Welcome to WebmasterWorld Guest from 54.196.232.162

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

selecting

     
9:09 am on Feb 27, 2009 (gmt 0)

New User

5+ Year Member

joined:Feb 26, 2009
posts:15
votes: 0


ok its a very simple thing i want to do
i have a text
example like
$text = 'its a example, the real text will be any thing';

now i want to do is select some words from 'text' (both before and after)
example
the real text will be

any idea how to do this ?

11:35 am on Feb 27, 2009 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 4, 2002
posts:385
votes: 0


You might be looking for the substr() function. You'll want to read the string functions on php dot net. Look for the "documentation" link at the top of the page.
1:08 pm on Feb 27, 2009 (gmt 0)

New User

5+ Year Member

joined:Feb 26, 2009
posts:15
votes: 0


i know about substr() its selecting the words but with the number od characters not with the text and i want with text...
4:39 pm on Feb 27, 2009 (gmt 0)

New User

5+ Year Member

joined:Jan 21, 2009
posts:24
votes: 0


you can split the content of the phrase into an array with each key representing a word in the phrase using the split function..

$text = 'its a example, the real text will be any thing';
$wordArray = split(" ", $text);

print_r($wordArray);

// wordArray[0] = its
wordArray[1] = a
wordArray[2] = example
......etc.....