Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001062

Re: [PHP-DB] number of occurences From: Hugh Bothwell (hugh_bothwell <email protected>)
Date: 06/24/01

> $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";

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>