Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Simple JSON Encode using PHP

<html>
<body>
<?php
$a=[1,2,1,1,2,3,90];
$b=[];
foreach($a as $i){
    if(array_key_exists($i,$b)){
        $b[$i]++;
    } else {$b[$i]=1;}
    
}
echo json_encode($a)."<br/>".json_encode($b);
?>
</body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.