Answers for "array indext print in php"

PHP
20

print array php

<?php
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
echo "<pre>";
print_r ($a);
echo "</pre>";
?>
  
Output:

Array
(
    [a] => apple
    [b] => banana
    [c] => Array
        (
            [0] => x
            [1] => y
            [2] => z
        )
)
Posted by: Guest on February-26-2020
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