marcus Posted December 9, 2006 Share Posted December 9, 2006 Is it possible to check if the same value of the submitted field are the same values?[code]<?php$str = $_POST['num'];if(strlen($str) > 0 && strlen($str) < 5){ //then check if the field is the same value (like 4444,3333,1111)}?>[/code] Link to comment https://forums.phpfreaks.com/topic/30011-question/ Share on other sites More sharing options...
The14thGOD Posted December 9, 2006 Share Posted December 9, 2006 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 More sharing options...
marcus Posted December 9, 2006 Author Share Posted December 9, 2006 Like, if the four values present are the same value, it would echo off like values are alike. Link to comment https://forums.phpfreaks.com/topic/30011-question/#findComment-137947 Share on other sites More sharing options...
The14thGOD Posted December 9, 2006 Share Posted December 9, 2006 Hmm, no idea on that one, sorry :(. Link to comment https://forums.phpfreaks.com/topic/30011-question/#findComment-137948 Share on other sites More sharing options...
roopurt18 Posted December 9, 2006 Share Posted December 9, 2006 Just get the first character, build a regexp out of it, and look for any non-matching chars. Link to comment https://forums.phpfreaks.com/topic/30011-question/#findComment-137950 Share on other sites More sharing options...
linuxdream Posted December 9, 2006 Share Posted December 9, 2006 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 More sharing options...
bljepp69 Posted December 9, 2006 Share Posted December 9, 2006 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,aaaaaDidn't match these - 111211,444442,Aaaaaa Link to comment https://forums.phpfreaks.com/topic/30011-question/#findComment-137958 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.