Alexey Kosov
0
Q:

php implode associative array

<?php 
/* 
There are 3 Types of array in php  
1. Indexed arrays - Arrays with a numeric index
2. Associative arrays - Arrays with named keys
3. Multidimensional arrays - Arrays containing one or more arrays

This is the second one - Associative arrays
*/

$age = array("Samy"=>"35", "Naveen"=>"37", "Amit"=>"43");
echo "Mr.Samy is " . $age['Samy'] . " years old.";

?>
6
$users = [
	'user1' => '[email protected]',
	'user2' => '[email protected]'
];

echo implode(', ',$users);
// "[email protected], [email protected]"
0
function myfunc(){
    $arr = array();
    $arr[] = 'value0';
    $arr['key1'] = 'value1';
    $arr['key2'] = 'value2';
    $arr[] = 'value3';
    return $arr;
}
0

New to Communities?

Join the community