


PHP has powerful functions, and more and more people are using it. Here we will give you a detailed introduction to PHP array initialization. From the first introduction to ASP to PHP, I feel that one of the strengths of PHP is the richness of built-in functions. For example, the PHP date and time functions I learned earlier, the related functions for reading and writing files, etc. all show that PHP is more professional and easier for users to use. Handy.
At first I was very excited about the rich functions of PHP functions. As I came into contact with more and more almost abnormal functions, I suddenly thought of the scarcity of ASP built-in functions. To complete a certain special function, it is often necessary to It is necessary to customize functions. As the number of applications increases, I actually have a set of commonly used function libraries. However, now in PHP, these functions have long been standardized, normalized and condensed into built-in functions for direct use. Former ASP developers have become ordinary users of PHP.
But on second thought, the existence of these functions and these large numbers of PHP functions at least shows that PHP is more professional; at the same time, it should be very fast and easy to use when processing our daily PHP programs, which makes development People no longer customize functions for basic and detailed functions, but focus on building more powerful program modules. Therefore, I have strengthened my belief in taking a look at PHP functions, but I think that in the future development process, the PHP function manual should be a portable book.
Of course, there is no need to discuss the debate about the advantages and disadvantages of ASP and PHP. Learning and understanding can help you understand the truth. To be honest, there are too many functions in PHP to prevent forgetting, so every time I read a type of function, I make a summary and collection work, and write a log for convenience.
PHP array initialization and definition
What is an array? An array is a programming structure that is a variable that stores a set or series of values. For example, the identity registration of individuals during the census, such as name, gender, ethnicity, birth, etc., can be used as an array. Creating an array in PHP is defined using the array() structure. PHP array initialization is such as:
<ol class="dp-c"><li class="alt"><span><span class="vars">$people</span><span>=</span><span class="keyword">array</span><span>(</span><span class="string">'name'</span><span>,</span><span class="string">'sex'</span><span>,</span><span class="string">'nation'</span><span>,</span><span class="string">'brith'</span><span>); </span></span></li></ol>
. As for how to display the value of each element in the array, we start from 0 The index, the index number is in square brackets after the variable name, for example:
<ol class="dp-c"> <li class="alt"><span><span><?php </span></span></span></li> <li> <span class="vars">$people</span><span>=</span><span class="keyword">array</span><span>(</span><span class="string">'name'</span><span>,</span><span class="string">'sex'</span><span>,</span><span class="string">'nation'</span><span>,</span><span class="string">'birth'</span><span>); </span> </li> <li class="alt"> <span class="func">echo</span><span> </span><span class="vars">$people</span><span>[2]; </span> </li> <li><span>?> </span></li> </ol>
The $people[2] output by copying the code shows nation (the first item in the index counts from 0). In addition to supporting numerically indexed arrays, PHP also supports related arrays. The so-called correlation array means that you can customize keywords to replace unintuitive numeric indexes, such as:
<ol class="dp-c"> <li class="alt"><span><span><?php </span></span></span></li> <li> <span class="vars">$peoples</span><span>=</span><span class="keyword">array</span><span>(</span><span class="string">'xm'</span><span>=></span><span class="string">'name'</span><span>,</span><span class="string">'xb'</span><span>=></span><span class="string">'sex'</span><span>,</span><span class="string">'mz'</span><span>=></span><span class="string">'nation'</span><span>,</span><span class="string">'cs'</span><span>=></span><span class="string">'birth'</span><span>); </span> </li> <li class="alt"> <span class="func">echo</span><span> </span><span class="vars">$peoples</span><span>[</span><span class="string">'cs'</span><span>]; </span> </li> <li><span>?> </span></li> </ol>
Copy the code and use the correlation array to make the output selection intuitive (no need to pre- Calculate the index number and then output), use the "=>" symbol between the defined keyword and value. According to the two display methods of PHP array elements, numbers can be automatically created directly without array() declaration and initialization like variables. For example,
<ol class="dp-c"> <li class="alt"><span><span class="vars">$people</span><span>[0]=</span><span class="string">'name'</span><span>; </span></span></li> <li> <span class="vars">$people</span><span>[1]=</span><span class="string">'sex'</span><span>; </span> </li> <li class="alt"> <span class="vars">$people</span><span>[2]=</span><span class="string">'nation'</span><span>; </span> </li> <li> <span class="vars">$people</span><span>[3]=</span><span class="string">'brith'</span><span>; </span> </li> </ol>
copy code or
<ol class="dp-c"> <li class="alt"><span><span class="vars">$peoples</span><span>[</span><span class="string">'xm'</span><span>]=</span><span class="string">'name'</span><span>; </span></span></li> <li> <span class="vars">$peoples</span><span>[</span><span class="string">'xb'</span><span>]=</span><span class="string">'sex'</span><span>; </span> </li> <li class="alt"> <span class="vars">$peoples</span><span>[</span><span class="string">'mz'</span><span>]=</span><span class="string">'nation'</span><span>; </span> </li> <li> <span class="vars">$peoples</span><span>[</span><span class="string">'cs'</span><span>]=</span><span class="string">'birth'</span><span>; </span> </li> </ol>
copy code. The size of the array changes dynamically according to the number of elements added.

作为一名Java开发者,学习和使用Spring框架已经是一项必不可少的技能。而随着云计算和微服务的盛行,学习和使用SpringCloud成为了另一个必须要掌握的技能。SpringCloud是一个基于SpringBoot的用于快速构建分布式系统的开发工具集。它为开发者提供了一系列的组件,包括服务注册与发现、配置中心、负载均衡和断路器等,使得开发者在构建微

近日,努比亚Z70Ultra在IMEI数据库中现身,型号为NX731J。该手机搭载了新一代屏下摄像头技术,将成为全球首款搭载骁龙8Gen4处理器的真全面屏旗舰手机,该手机最大的亮点是采用了1.5K分辨率的屏下摄像头方案,这是目前行业内分辨率最高的UDC(屏下摄像头)技术。此前努比亚已量产第六代屏下摄像技术(屏幕分辨率为2480×1116,介于FHD和1.5K分辨率之间),而Z70Ultra的屏幕分辨率提升至1.5K,实现了无刘海、无挖孔的真全面屏设计。1.Z70Ultra搭载一英寸超大底主摄传感

win7系统自带有备份还原系统的功能,如果之前有给win7系统备份的话,当电脑出现系统故障的时候,我们可以尝试通过win7还原系统修复。那么win7怎么还原系统呢?下面小编就教下大家如何还原win7系统。具体的步骤如下:1、开机在进入Windows系统启动画面之前按下F8键,然后出现系统启动菜单,选择安全模式登陆即可进入。2、进入安全模式之后,点击“开始”→“所有程序”→“附件”→“系统工具”→“系统还原”。3、最后只要选择最近手动设置过的还原点以及其他自动的还原点都可以,但是最好下一步之前点击

随着Web应用程序的需求越来越高,PHP技术在开发领域中变得越来越重要。在PHP开发方面,测试是一个必要的步骤,它可以帮助开发者确保他们创建的代码在各种情况下都可靠和实用。在PHP中,一个流行的测试框架是PHPUnit。PHPUnit是一个基于Junit的测试框架,其目的是创建高质量、可维护和可重复的代码。下面是一些学习使用PHPUnit框架的基础知识和步骤

荣耀MagicBookPro14惊艳发布,引领AIPC新时代!在MWC开幕前夕,荣耀抢先在国内发布了全新MagicBookPro14笔记本,并同步推出AIPC2.0战略,以AI技术全面革新笔记本电脑体验。荣耀AIPC2.0战略涵盖AI内核驱动的智能硬件、AI智能体赋能的人机交互以及AI服务流转的跨端生态。荣耀手机广受好评的“一句话的事”AI交互体验也将在MagicBookPro14上实现,用户只需语音指令即可完成操作。搭载全新HONORTurboX技术,MagicBo

香港中文大学(深圳)吴保元教授课题组和浙江大学秦湛教授课题组联合发表了一篇后门防御领域的文章,已顺利被ICLR2022接收。近年来,后门问题受到人们的广泛关注。随着后门攻击的不断提出,提出针对一般化后门攻击的防御方法变得愈加困难。该论文提出了一个基于分割后门训练过程的后门防御方法。本文揭示了后门攻击就是一个将后门投影到特征空间的端到端监督训练方法。在此基础上,本文分割训练过程来避免后门攻击。该方法与其他后门防御方法进行了对比实验,证明了该方法的有效性。收录会议:ICLR2022文章链接:http

Laravel是一个基于PHP的开源Web应用程序框架,是当今最受欢迎的框架之一。它的设计思想是以简单、优雅的方式解决复杂的问题,为开发Web应用程序提供了丰富的工具和资源。如果你想在PHP中学习Laravel框架,下面是几个关键步骤:第一步:安装和配置Laravel在开始使用Laravel之前,您需要安装PHP和Composer。Composer是一个PH

随着win10系统的成熟,微软停止win7的更新和支持,越来越多人选择win10系统使用,打算将自己的win7升级win10系统。不过很多小伙伴不知道win7如何升级win10系统,找不到升级的按键。下面小编教大家一个简单的win7升级win10系统的方法。我们可以借助工具轻松实现win7升级安装win10的方法,具体的操作步骤如下:1、先在电脑上下载安装小鱼一键重装系统工具并打开,关闭电脑的杀毒软件,备份c盘重要资料。然后选择需要安装的win10系统点击安装此系统。2、这个界面选择想要安装的软


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment