Jump to content

[SOLVED] Explode Twice


twofivethreetwo

Recommended Posts

I have a sql row with this information:

11/12/07.10am.vs Lions|11/13/07.9am.vs Sharks|11/15/07.9am.Practice|11/16/07.10am.Practice|11/18/07.11am.vs Frogs|

 

I need to explode the events and then explode the sections. So, basically I need to explode the | which separates the events. Then I need to explode . that separates each item in the event.

 

How would this look? I have tried different things exploding and foreach and just haven't gotten it to work yet. The above basically needs to create a tables of events...

Link to comment
https://forums.phpfreaks.com/topic/77480-solved-explode-twice/
Share on other sites

Give this a try, I'm not sure exactly how you wanted it formatted, but I got everything into separate pieces for you.

 

<?php

$lines = "11/12/07.10am.vs Lions|11/13/07.9am.vs Sharks|11/15/07.9am.Practice|11/16/07.10am.Practice|11/18/07.11am.vs Frogs|";
$lines = explode('|', $lines);

foreach ($lines as $line){
   $line = explode('.', $line);
   
   echo "<b>Date:</b> $line[0]<br>";
   echo "<b>Time:</b> $line[1]<br>";
   echo "<b>Your Team</b> $line[2]<p>";
}

?>

Link to comment
https://forums.phpfreaks.com/topic/77480-solved-explode-twice/#findComment-392228
Share on other sites

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.