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
https://forums.phpfreaks.com/topic/134690-preg_match-help/
Share on other sites

So at each number (2.3 etc.) you want it to go into an array and then arrange them into an order highest to lowest.

 

If so i think a mixture between explode and i think it is called sort(); should work

 

http://www.php.net/explode

http://uk3.php.net/manual/en/function.sort.php

Link to comment
https://forums.phpfreaks.com/topic/134690-preg_match-help/#findComment-701358
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.