Question:

What's that PHP function....?

by  |  earlier

0 LIKES UnLike

What's the PHP function that will count the number of occurrences of something within a string?

My registration script needs to check password strength, and in order to do that I need to count the number of numbers within a password.

So, I need the function that given "$password" will search and count the numbers in it.

How would I go about this? Regex?

 Tags:

   Report

3 ANSWERS


  1. Simply do like below:

    -----StartCode-----

    <?php

    echo mb_substr_count("This is a test", "is"); // 2

    ?>

    -----CodeEnd-----

    See also: http://php.net/mb_substr_count


  2. checking password strength would best be done with javascript

  3. strlen($password) will tell you how many characters in your string.

    Good luck,

    peng

    FixExpress is a FIX gateway.

    http://www.eptop.com/FIX/FixExpress.htm

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.