1 Replies - 202 Views - Last Post: 29 November 2012 - 11:31 PM

#1 hwoarang69  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 171
  • Joined: 23-October 12

compare string, caps dont matter

Posted 29 November 2012 - 10:58 PM

i want to test these all strings are same

$s1 = dave; $s2 = Dave; $s3 = dAve; $s4 = daVe; $s5 = davE; $s6 = DAve; $s7 = DaVe; $s8 = DavE; $s9 = DAVE;




i want to check all s1, to s9 are same as 'dave'. it should matter the caps. i tryed useing strstr bc its insensitive. but it doesnt work. i read some where you have to put '!' when using strstr. is this true?


if((strstr($s1, 'dave'))) 

This post has been edited by hwoarang69: 29 November 2012 - 11:04 PM


Is This A Good Question/Topic? 0
  • +

Replies To: compare string, caps dont matter

#2 Hqtitan  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 51
  • Joined: 28-August 10

Re: compare string, caps dont matter

Posted 29 November 2012 - 11:31 PM

If capital characters don't matter, you can use the strtolower method, which will change all alphabetic characters in the string to lowercase.

Also, here is documentation on strstr, which is case-sensitive: http://php.net/manua...tion.strstr.php

Apparently, the stristr method is case-insensitive.

This post has been edited by Hqtitan: 29 November 2012 - 11:32 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1