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