jmurch Posted April 16, 2009 Share Posted April 16, 2009 I am trying to match a string that contains (anywhere in the string): '/var/iso/*.pdf' I have tried many different combinations with no luck yet. TIA, Jeff Link to comment https://forums.phpfreaks.com/topic/154284-search-filter/ Share on other sites More sharing options...
.josh Posted April 16, 2009 Share Posted April 16, 2009 just check if it's there: if (preg_match('~/var/iso/.*?\.pdf~',$string)) { // it's there, do something } match and capture: preg_match('~(/var/iso/.*?\.pdf)~',$string,$match); echo $match[1]; match more than once and capture: preg_match_all('~(/var/iso/.*?\.pdf)~',$string,$matches); print_r($matches); Link to comment https://forums.phpfreaks.com/topic/154284-search-filter/#findComment-811127 Share on other sites More sharing options...
premiso Posted April 16, 2009 Share Posted April 16, 2009 Just out of curiosity, it seems like you are testing if a file exists? Maybe glob will help you. Given that no code was shown, I do not know. But that may be what you are after in the first place So I thought I would point that out. Link to comment https://forums.phpfreaks.com/topic/154284-search-filter/#findComment-811131 Share on other sites More sharing options...
nrg_alpha Posted April 16, 2009 Share Posted April 16, 2009 In the event of preg_match_all, multi-dimensional array(s) will result, so one may want to echo $matches[0] instead for the desired results. Link to comment https://forums.phpfreaks.com/topic/154284-search-filter/#findComment-811132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.