note 31211 deleted from function.str-word-count by alindeman
| From: | alindeman@php.net | Date: | Mon, 14 Apr 2003 11:26:43 +0000 |
| Subject: | note 31211 deleted from function.str-word-count by alindeman | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-46590@lists.php.net to get a copy of this message | ||
//here's an example of how to check if the string has properly
//closed brakets for ex. if it has (())(()(())) or ))(())((()))))))
//using stack, returns true if the string is ok,
//and false otherwise
//i'm not used to programming in php so, don't mind the
//mistakes, if u've got any suggestions or questions go to my site - h**p://www.torsoft.tk
function validate ($string){
$Stack=array("");
$i=-1;
while ($i++<strlen($string)){
$ft=substr($string,$i,1);
if ($ft=="(") array_push($Stack,$ft);
elseif ($ft==")") array_pop($Stack);
}
return sizeof($Stack)==0;
}