Answers for "how to print array assosative in php"

PHP
2

print array items in php

<?php $data = array('a'=>'apple','b'=>'banana','c'=>'orange');?>
<pre><?php print_r($data); ?></pre>
Posted by: Guest on July-15-2021
0

print asociative array php

//This is the declaration of an associative array.
$animals["firstindex"]="ape";
$animals["secondindex"]="dinosaur";
$animals["thirdindex"]="ahahah";
for(reset($animals);$element=key($animals);next($animals))
{print("$element is $animals[$element]");
}

//Can also be created by using an array function
$fourth=array("January"=>"first","February"=>"second","March"=>"third","April"=>"fourth");
foreach($fourth as $element=>$value)
print("$element is the $value month");
Posted by: Guest on December-06-2020

Browse Popular Code Answers by Language