note 31211 added to function.str-word-count
| From: | admin at torsoft dot tk | Date: | Mon, 14 Apr 2003 03:35:15 +0000 |
| Subject: | note 31211 added to function.str-word-count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46579@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;
}
--
http://www.php.net/manual/en/function.str-word-count.php
http://master.php.net/manage/user-notes.php?action=edit+31211
http://master.php.net/manage/user-notes.php?action=delete+31211
http://master.php.net/manage/user-notes.php?action=reject+31211