skyer2000 Posted August 15, 2007 Share Posted August 15, 2007 What I have is hundreds of names, such as this-1 this-2 this-3. The if statement I have so far is if($blah == "this-") How can I make it so that the if statement will be true if $blah at least matches 'this-' ? Link to comment https://forums.phpfreaks.com/topic/65119-solved-if-statement-with-wildcard-characters/ Share on other sites More sharing options...
Orio Posted August 15, 2007 Share Posted August 15, 2007 This will match everything that starts with "this-". if(ereg("^this-", $blah)) Orio. Link to comment https://forums.phpfreaks.com/topic/65119-solved-if-statement-with-wildcard-characters/#findComment-325003 Share on other sites More sharing options...
skyer2000 Posted August 15, 2007 Author Share Posted August 15, 2007 I had to change it to if(ereg("/this-", $blah)) and it worked great. Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/65119-solved-if-statement-with-wildcard-characters/#findComment-325048 Share on other sites More sharing options...
Orio Posted August 15, 2007 Share Posted August 15, 2007 The "^" sign is important... In your case strings like "abc123 this-1" will match. Orio. Link to comment https://forums.phpfreaks.com/topic/65119-solved-if-statement-with-wildcard-characters/#findComment-325051 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.