Jump to content

preg_split and explode - help needed


melbfella

Recommended Posts

G'day all,

 

I'm a PHP newbie (been an ASP programmer for years) and am trying to split a string of data up so I can use the individual pieces.

 

The data looks something like this :

 

2013-04-07 15:59:15,895~2013-04-07 16:01:15,897~2013-04-07 16:02:25,893

The split character is the tilde (~). 

 

I then wish to iterate through each item, split the item on the comma, and use the 2 values in a web page.

 

I've tried to use preg_split and explode, but just can't get it going - any and all help would be much appreciated.

 

Cheers.

Link to comment
https://forums.phpfreaks.com/topic/276633-preg_split-and-explode-help-needed/
Share on other sites

The easiest solution here would be to just use explode (twice), and a simple foreach loop.

Also, since you didn't post what you've tried I cannot tell you why it's wrong. So please post your attempts at solving this, so that we can guide you on how to properly do it.

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.