• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
preg_replace help needed

#1
[eluser]CISCK[/eluser]
So, I have a comma delimitated string of 24 hour times:

Code:
$hours = "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23";

I am matching each number in the string using:

Code:
$pattern = '/\d+/';

What would be the correct replacement to achieve:

12am, 1am, 2am, 3am, 4am, 5am, 6am, 7am, 8am, 9am, 10am, 11am, 12pm, 1pm , 2pm, 3pm, 4pm, 5pm, 6pm, 7pm, 8pm, 9pm, 10pm, 11pm

Thanks!

--

Code:
$hours = "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23";
$pattern = '/\d+/';
$replacement = 'PLEASE HELP!';
preg_replace($pattern, $replacement, $hours);


Messages In This Thread
preg_replace help needed - by El Forum - 10-31-2009, 07:53 AM
preg_replace help needed - by El Forum - 10-31-2009, 08:46 AM
preg_replace help needed - by El Forum - 10-31-2009, 09:21 AM
preg_replace help needed - by El Forum - 10-31-2009, 10:27 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.