خرید بک لینک

Vote count: 0

I am new to PHP Development. I want to be able to store each of the character count of a word in an array.

so if word is "test".

I want something like

arr[t] = 2
arr[e] = 1
arr[s] = 1

In terms to ASCII I would actually want something like:

arr[116] = 2
arr[101] = 1
arr[115] = 1

Below is what I have tried:

 <?php
    $content = file_get_contents($argv[1]);
    $arr = explode(" ", $content);
    $arrlength = count($arr);
    echo $arrlength;
    echo " ";
    $countArr = array();
    for($x = 0; $x < strlen($arr[0]); $x++)
    {
        $countArr[$arr[0][$x]]++;    // taking first word 
    }
    for($x = 0; $x < 256; $x++)
    {
        $countArr[$x];    // trying to print the count values  
    }
    ?>

It does not seem to work. In c++ I used to do something like this and it used to work. Am i missing something here. Please help.

asked 43 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 13 تير 1395 ساعت: 10:47

صفحه بندی