Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[PHP] Seeing if a character is not one of those in an array

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Mattraks
How do I cheat?
Reputation: 0

Joined: 21 Oct 2007
Posts: 0
Location: IRAQ!

PostPosted: Sat Nov 01, 2008 4:26 pm    Post subject: [PHP] Seeing if a character is not one of those in an array Reply with quote

Code:
function CheckIncLink($path){
   $legal_strings = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "/");
   foreach($legal_strings as $lstring){
      $bTempGood = false;
      for($i=1; $i<strlen($path)+1; $i++){
         if(strcmp(StrToLower($path[$i]), $lstring) == 0){
            $bTempGood = true;
            break;
         }
      }
      if($bTempGood == false) {
         return false;
      }
   }
   return true;
}


Well, its supposed to check each character in $path and if it isn't one in the array, then it will return false. It always returns true. Anyone know how to fix it?

_________________
FOR ALLAH!
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Nov 01, 2008 4:48 pm    Post subject: Reply with quote

Code:

         if(strcmp(StrToLower($path[$i]), $lstring) != 0){
            return false;
         }

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Sat Nov 01, 2008 8:47 pm    Post subject: Reply with quote

what samuri said and don't forget to remove

Code:


    if($bTempGood == false) {
         return false;
      }

completely useless

and remove all the $bTempGood 's they are not needed if you want it to be true just return true if you want it to be false just return false you dont need a variable for it.

You don't have to use arrays you could use built in functions (much much faster)

http://us.php.net/manual/en/function.ctype-alpha.php
to check for abc's only (letters)
http://us.php.net/manual/en/function.ctype-alpha.php
to check for abc's and 123's (Numbers and letters)
http://us.php.net/manual/en/function.ctype-digit.php
to check for 123's only (numbers)
http://us.php.net/manual/en/function.ctype-lower.php
to check for ABCS if any not lower case .. tons of these functions you will see them all..


http://us.php.net/is_numeric
duplicate function same as ctype-digit to check for 123's only (i think this one was made first.. before the ctypes)

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites