Y
Y
Yuri2019-10-09 13:49:55
Arrays
Yuri, 2019-10-09 13:49:55

Who will help to deal with the php array?

There is a variable

$all = "13,07,03,08,15,22,12,23,19,21,04,09,21,01,03,10,09,22";

there is a script that counts the number of identical numbers in a string
$a=array(13,07,03,08,15,22,12,23,19,21,04,09,21,01,03,10,09,22);
$b=array();
sort($a);
 
foreach($a as $k=>$v)
{
    $b[$v][]=$v;
}
 
echo 'Найдено: <br>';
foreach($b as $k => $v){
    echo 'значение-&nbsp'.$k.'&nbsp встречается &nbsp'.count($v).'&nbsp раз(раза) <br>';
}

I need to make this line like this: that is, instead of numbers, there should be a variable with these numbers ... but then the array does not work and, accordingly, the script too. What am I doing wrong...?
$a=array($all);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stimulate, 2019-10-09
@elcity

$a = explode(',', $all);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question