SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Match the string
-
Oct 11, 2009, 09:31 #1
- Join Date
- Jun 2008
- Posts
- 205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Match the string
Code:<?php $file = array('2009/01/04/b3justin04cmmv,.nzsfoiwauf','2009/01/11/ymtestdrive11bnk,hhukt7yufgv','2009/01/13/a2correx13, bvj,hgho'); foreach($file as $f){ print "The input is : $f"; preg_match("/(\d{4}\/\d{2}\/\d{2}\/[^ ]*)/","$f",$match); print "The output is : $match[0]\n"; }
How to remove "," comma at the end. and find the last string before ","
-
Oct 11, 2009, 10:55 #2PHP Code:
<?php
$file = array('2009/01/04/b3justin04cmmv,.nzsfoiwauf','2009/01/11/ymtestdrive11bnk,hhukt7yufgv','2009/01/13/a2correx13, bvj,hgho');
foreach($file as $f){
print "The input is : $f<br />";
preg_match("/(\d{4}\/\d{2}\/\d{2}\/[^ ]*)/","$f",$match);
####
$foo=explode(',',$f);
echo '<p>'.$foo[0].'</p>';
####
print "The output is : $match[0]\n<br />";
}
?>
Bookmarks