Jump to content

devide up string from mysql


robcrozier

Recommended Posts

hi, does anyone know how i can divide up a string fetched from a database field. Basically i have a string which contains individual values separated by <br> in the database field. I don't just want to print out the string with the <br> which will merely put the individual values on a new line. I would like to completely break up the string so i can have full control over each value. Here's an example of what the database field would look like:

value1<br>value2<br>value3<br> ...

I want to be able to break this up into individual values (i.e value1, value2, value3)

Thanks for your help!!!
Link to comment
Share on other sites

For something like this you are better off doing it in your result loop, you can do it in the database with some string functions, but it would be better done in your script, because you would need 6 db functions, two for each variable just to return each part.

[code]while ( $row = mysql_fetch_assoc ( $result ) )
{
list ( $value1, $value2, $value3 ) = explode ( "\r\n", $row['fiend_name_to_split'] );

echo $value3;
}[/code]

Where "\r\n", would be "\r\n" on Windows, "\n" on Unix/Linux, "\r" on Mac/OS X


printf

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.