Jump to content

Case sensitive strpos


eon201

Recommended Posts

Im searchina string for the characters ' PIN='. It works and pulls up the what I have searched for.

 

The only problem is that it is also pulling up ' pin=' -notice the non caps

 

Why is this? Can I force the function to be case sensitive?

 

$findme22 = ' PIN=';
$pinfinder = strpos($line, $findme22);

 

Thanks. Eon201 ;D

Link to comment
https://forums.phpfreaks.com/topic/79421-case-sensitive-strpos/
Share on other sites

Another quick question about these two functions mentioned above.

 

When seaching for a pattern in the string, will php pick up on the fact that I am looking for ' PIN=' or will it automatically ignore the whitespace???

 

This is very important in my search criteria.

Is there some syntax that is specific to whitespace when using php??

 

Thanks. Eon201

Link to comment
https://forums.phpfreaks.com/topic/79421-case-sensitive-strpos/#findComment-402070
Share on other sites

Another quick question about these two functions mentioned above.

 

When seaching for a pattern in the string, will php pick up on the fact that I am looking for ' PIN=' or will it automatically ignore the whitespace???

 

The manual doesn't say anything about whitespace specifically, but as it matches full strings, it's logical that the spaces will be matched as well. If you get into a situation where you are needing to actually match a true pattern rather than a static string, use preg_match() instead so you can use regular expressions to define your pattern criteria.

Link to comment
https://forums.phpfreaks.com/topic/79421-case-sensitive-strpos/#findComment-402074
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.