给数组增加元素_PHP

WBOY
Release: 2016-06-01 12:30:25
Original
824 people have browsed it



给数组增加元素


 $Cities[] = "北京"; //等同于$Cities[0] = "北京"
 $Cities[] = "天津"; //等同于$Cities[1] = "天津"
 $Cities[] = "上海"; //等同于$Cities[2] = "上海"
 $Cities[] = "深圳"; //等同于$Cities[3] = "深圳"
 /*
 ** 统计元素个数
 */
 $indexLimit = count($Cities); //把数组中元素的个数赋给$indexLimit
 /*
 ** 打印所有数组
 */
 for($index=0; $index  {
  print("第 $index 个城市是 $Cities[$index]。
\n");
 }
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!