string count chars function - returns array counting the number of occurrences of character from given string

string count_chars function - returns array counting the number of occurrences of character from given string

string-count-chars-function-example-in-php.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>string count_chars function - returns array counting the number of occurrences of character from given string</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="Author" content="Md Iqbal Hosan">
  <meta name="title" content="string count_chars function - returns array counting the number of occurrences of character from given string">
  <meta name="keywords" content="php, example, code, array, function, count_chars, string">
  <meta name="description" content="string count_chars function - returns array counting the number of occurrences of character from given string">
  <style>
   h2, h4{background:#ccc; color:#000085;}
   h2{ padding:3px; margin:3px; font-size:21px;}
   h4{ padding:2px; margin:2px; font-size:17px;}
   p{padding:2px; margin:2px; color:#3333Fa;}
   body{ background:#FFFFFb;}
  </style>
 </head>
 <body>
  <h2>string count_chars function - returns array counting the number of occurrences of character from given string</h2>
  <pre>
   <?php
    /*
     --------------------------------------------------
     let us make an string to test the subject matter
     --------------------------------------------------
    */
    $myString = "My boss cfsuman is an seo specialist.";
    echo "<h4>Output of myString</h4>";
    print "<p>$"."myString = {$myString}</p>";
    /*
     ----------------------------------------------------------------------------------
     now we want to count the number of occurrences of characters of the given string
     by using count_chars string function
     ----------------------------------------------------------------------------------
    */
    $counterArray = count_chars($myString, 1);
    echo "<h4>Output of counterArray by using string count_chars function</h4>";
    print_r($counterArray);
    /*
     --------------------------------------------------------------------------------
     the array contains ascii values of character as keys and number of occurrences 
     of the character as values
     --------------------------------------------------------------------------------
    */
   ?>
  </pre>
 </body>
</html>

string count_chars function - returns array counting the number of occurrences of character from given string - output in the browser

No comments:

Post a Comment

leave your comments here..