How to Remove Bulk Dynamic Date Format in PHP?

$3
=
$0
+
$3
$3 Bitcoin bounty has been announced by author.
$0 has been already awarded by author.
$3 remains available.
0

i have the following text, and i want to remove any sentence that contains keywords representing calendar month. For example, here is the original text to be processed:

$mysent = 'Jul 2, 2014 . I went to special place. Aug 30, 2015 . We went to Paris.';

I try to use this array :

$sasi   = array('Jan ','Feb ','Mar ','Apr ','May ','Jun ','Jul ','Aug ','Sep ','Oct ','Nov ','Dec ');
$angka  = range(1,2015); 
$bulan  = $sasi.$angka.", ".$angka;

$contoh = str_replace($bulan,'',$contoh);

echo $contoh;

but the date format didn't removed, help me, thanks!

Tags:
interesting ...

Thanks dude! Here is my tip!!! (approx 0.00285 BTC)

1 Answer - total earned - 2.86 mBTC ($1 USD)

1
=
1
=
$1
1 tip with total amount of 2.86 mBTC($1 USD) have been sent by alex

You can use Regular Expressions:

$string = 'Jul 2, 2014 . I went to special place. Aug 30, 2015 . We went to Paris.';
$result = preg_replace('/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d+,\s\d{4}\s\.\s/i', '', $string);
echo $result;

Outputs:

I went to special place. We went to Paris.

PHPFiddle Link: http://www.phpfiddle.org/main/code/h82y-ucku

SEND BITCOIN TIPS

Thanks for this answer, here is my tip!

0

Post Answer


Will Bitcoin Tipping become a new Internet Culture?


Please share our story! THANK YOU!