分享

php array

 mylib972 2014-05-18

是否需要在推键的使用关联数组中的项目?那么你的祈祷在这里找到答案与此()函数。您只需指定数组的键和值对。我们必须小心,如果键已经在数组中存在,将超过撰写。

<?php
/*** an array of attributes about a dog ***/
$array = array('animal'=>'dog', 'name'=>'Offenbach', 'owner'=>'Mr Smith');

/*** add the dogs favourite food to the array ***/
$array = ($array, 'food', 'postmans leg');

/*** print the array ***/
print_r($array);

/**
 * @Push and element onto the end of an array with associative key
 *
 * @param array $array
 *
 * @string $key
 *
 * @mixed $value
 *
 * @return array
 *
 */
function ($array, $key, $value){
 $array[$key] = $value;
 return $array;
}

?>

This will return the following results

Array
(
   [animal] => dog
   [name] => Offenbach
   [owner] => Mr Smith
   [food] => postmans leg
)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多