php return array code example
Example 1: php return array
<?php
function data() {
$out[0] = "abc";
$out[1] = "def";
$out[2] = "ghi";
return $out;
}
$data = data();
foreach($data as $items){
echo $items;
}
Example 2: php return associative array
function myfunc(){
$arr = array();
$arr[] = 'value0';
$arr['key1'] = 'value1';
$arr['key2'] = 'value2';
$arr[] = 'value3';
return $arr;
}