Jump to content

preg_match help


n3mesis125

Recommended Posts

Hey folks,

 

I'm looking for away to put in line breaks at certain patterns in text. Not sure if this is possible, but I'll give an example string and then what I'd like to see come out of it.

 

<?php

$string = "3.2 Here is the infor for this one 4.5 This is a test 5.0 Here we go";

?>

 

What I'm trying to do is search for an integer pattern for the numbers and use a line break. So the only thing at the moment that I can see could throw it off is if there is one in the beginning. I'd like to see the above string put into an array of

 

<?php

$myArray = array(
  [0] => '3.2 Here is the info for this one',
  [1] => '4.5 This is a test',
  [2] => '5.0 Here we go');

?>

 

Is this possible?

 

Thanks,

n3m.

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.