tags:

views:

65

answers:

3

both conditions returns false,how to distinguish them?

can it be done without using the third parameter?

A: 

Perhaps you can put some sample code here, but you can look into the fifth argument: $count, which is the number of replacements done.

動靜能量
A: 

You may be talking about strpos which returns false if it doesn't match anything or 0 if the 'needle' matches the very start of the 'haystack'. These are both 'falsey' values, so you need to explicitly check them with a triple equals operator:

if (strpos($haystack, $needle) === false) {
    // $needle NOT found in $haystack.
} else {
    // $needle was found in $haystack.
}
miknight
A: 

preg_replace can have multiple references, so if you made you first reference something like /^(.){min,max} where min/max is your minimum/maxium number of characters you're trying to match in the beginning, that match would be \\1 and the next set of parens would be \\2 and so on.

Without more information, its hard to tell if this or other solutions will work.

NeuroScr