In fact, broadly speaking, PHP is a C language application on the Web Template, php smarty template used more, like JSP is a Java servlet template (oh, yes, JSP has a jstl tag), complex template syntax is difficult to be welcomed by developers.
In PHP, arrays are implemented using Hashtable. PHP uses a number of mechanisms that allow for the addition and deletion of arrays in the time Complexity of O (1), while supporting both linear traversal and random access.
The order in which foreach iterates through an array in PHP is related to the order in which the elements are added.
If you want to traverse the index size in an array of numeric indexes, you should use for instead of foreach.
RELATED links:
http://yanpeipan.github.io/2014/12/18/understandable PHP array/
Http://www.laruence.com/2009/08/23/1065.html
PHP kernel in-depth study-arrays and their traversal order