sandy1028 Posted October 11, 2009 Share Posted October 11, 2009 <?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 extract only "2009/01/04/b3justin04cmmv","2009/01/11/ymtestdrive11bnk","2009/01/13/a2correx13". How to remove "," comma at the end. and find the last string before "," Quote Link to comment https://forums.phpfreaks.com/topic/177321-match-the-string/ Share on other sites More sharing options...
.josh Posted October 11, 2009 Share Posted October 11, 2009 foreach ($file as $f) { $f = explode(',',$f); echo $f[0]; } Quote Link to comment https://forums.phpfreaks.com/topic/177321-match-the-string/#findComment-934925 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.