Re: number of occurences

From: Date: Sun, 24 Jun 2001 17:38:28 +0000
Subject: Re: number of occurences
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-9794@lists.php.net to get a copy of this message
> $number = 123782301247832; > Now, I'd like to check how many times the letter 1 occurs in there... Try this: $number = "123782301247832"; $res = count_chars($number, 1); $outstr = ""; foreach($res as $key => $val) { if ($outstr != "") $outstr .= ", "; $outstr .= $val." '".htmlentities(chr($key))."'s"; } echo "<br>'$number' contains $outstr";

« previous php.db (#9794) next »