Jump to content

Question


marcus

Recommended Posts

I could be way off..because I'm not sure exactly what you are talking about. But like if you have a password and a confirm password?
This is what I did:
[code]
if($password == $confirm_pw) {
//Action here
}
[/code]

If that's not what you are talking about then I apologize ^_^.

The14thGOD
Link to comment
https://forums.phpfreaks.com/topic/30011-question/#findComment-137946
Share on other sites

You're going to have to clarify on that a bit...

Do you mean check the length then see if the value for the length is the actual value repeated that many times????

<?php
$str = $_POST['num']
$length = strlen($str);

if(($str == $length) && ($str == str_repeat($length, $length))){
  //Condition is true
}
?>

I think that will work.

Of course that will only work on numbers under 10
Link to comment
https://forums.phpfreaks.com/topic/30011-question/#findComment-137955
Share on other sites

This should work to see if all characters in the field are the same:
[code]
<?php
  $str = $_POST['num'];
  $char1 = substr($str,0,1); //grabs the first character of the string
  if (preg_match("/^[$char1]*$/",$str)) { //checks to see if $str begins and ends with $char1 and only contains $char1
    //condition is true
  }
?>
[/code]

Matched these test conditions - 11111,44444,aaaaa
Didn't match these - 111211,444442,Aaaaaa
Link to comment
https://forums.phpfreaks.com/topic/30011-question/#findComment-137958
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.