Created
November 13, 2013 09:00
-
-
Save ihsanberahim/7445918 to your computer and use it in GitHub Desktop.
separate text by breakline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$subject = ' | |
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test | |
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test | |
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test | |
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test | |
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test | |
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test | |
RM 1,999.01 test RM 1,999.012121 test RM 1,999.01 test RM 1,999.012121 test | |
'; | |
$linebyline = explode("\n",$subject); | |
$noRM = array(); | |
echo 'Original'; | |
var_dump($linebyline); | |
//Filter empty line | |
foreach($linebyline as $key => $line): | |
if(empty($line)) | |
{ | |
unset($linebyline[$key]); | |
} | |
endforeach; | |
foreach($linebyline as $key => $line): | |
if(strpos($line,'RM')===false): | |
$noRM[]=$linebyline[$key]; | |
unset($linebyline[$key]); | |
endif; | |
endforeach; | |
echo 'With Rm'; | |
var_dump($linebyline); | |
echo 'Without Rm'; | |
var_dump($noRM); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment