String tokenizAr

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Julia
Forum Newbie
Posts: 1
Joined: Tue Oct 09, 2007 11:30 pm

String tokenizAr

Post by Julia »

scottayy | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi!

Im [s]kinda[/s] [b]kind of[/b] newbie to php and have been looking for some tokenizer [s]kinda[/s] [b]kind of[/b] functions in php to deal with my problem
I´d appreciate some help [s]vrrry[/s] [b]very[/b] much

I have an input which basically recieves a string of text like this:

blah blah1 blah2 blah3 
blah4 blah5...

I would like to have a function to take that input and transform it into this:
[syntax="html"]<div id="blah">blah</div>  <div id="blah1">blah1</div>  <div id="blah2">blah2</div>  <div id="blah3">blah3</div> <div id="blah4">blah4</div>
and then...[/syntax]

Code: Select all

$my_string= <div id="blah">blah</div>  <div id="blah1">blah1</div>  <div id="blah2">blah2</div>  <div id="blah3">blah3</div> <div id="blah4">blah4</div>

then i want to display that same original text in a webpage but know enclosed in the div tags
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.

scottayy | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

preg_replace() could also perform this action with a fairly simple expression.
Post Reply