Jump to content

[SOLVED] Finding a string within a string - 2 different locations


refiking

Recommended Posts

I have records in a db like this

line1<br>

line2<br>

 

What I need are 2 different variables.  Here's the code I have (or more of what I need)

 

while ($row = mysql_fetch_assoc($sql){
$line1 = //everything before the <br> tag
$line2 = //everything between the two <br> tags

Well, that code is incorrect because your missing a bracket off your while() loop.

 

So, basically you have 2 lines in your database, in the one field. And you stored at <br> tag in there as well? Or is it a newline? Hm, please explain a bit more.

 

Here is what I'm thinking though.

 

while($row = mysql_fetch_assoc($sql)){
$lines = explode("<br>", $row['field']);
$line1 = $lines[0]; //Should hold line1
$line2 = $lines[1]; //Should hold line2
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.