Home  >  Article  >  A brief discussion of tutorial examples of primitive arrays

A brief discussion of tutorial examples of primitive arrays

零下一度
零下一度Original
2017-06-14 21:24:162001browse

php The print_r method can print and display variables to make them easy to understand. If the variable is a string, integer or float, the variable value itself will be printed. If the variable is an array, the keys and elements will be displayed in a certain format. object is similar to an array. print_r is used to print large arrays. PHP natively does not restore the data printed by the print_r method to the original array, so the following method was written to restore the data processed by print_r to the original array. RestorePrint.class.php

1. php method to restore the data processed by print_r to the original array

A brief discussion of tutorial examples of primitive arrays

Introduction: The PHP print_r method can print and display variables to make them easy to understand. If the variable is a string, integer or float, the variable value itself will be printed. If the variable is an array, the keys and elements will be displayed in a certain format. object is similar to an array. print_r is used to print large arrays.

2. Delete, replace and add array elements

A brief discussion of tutorial examples of primitive arrays

##Introduction: Syntax: splice(index,len,[item]) This method will change the original array. splice has 3 parameters. It can also be used to replace, delete, and add one or more values ​​in the array. index represents the starting subscript of the array, len represents the length of replacement/deletion, and item represents the replaced value. In case of deletion operation, item is empty. Example: 1 Delete: var arr = ['a','b','c','d']; arr.splice(1,2); console.log(arr) ...

3. Delete, replace and add array elements

A brief discussion of tutorial examples of primitive arrays

##Introduction: Syntax: splice( index,len,[item]) This method will change the original array. splice has 3 parameters. It can also be used to replace, delete, and add one or more values ​​in the array. index represents the starting subscript of the array, len represents the length of replacement/deletion, and item represents the replaced value. In case of deletion operation, item is empty. Example: 1 Delete: var arr = ['a','b','c','d']; arr.splice(1,2); console.log(arr) ...

4.

After seeing the moderator’s infinite classifications and dividing them into tree structures, how to restore them?

Introduction: After seeing the moderator’s infinite classifications and dividing them into tree structures, After the tree structure, how to restore the original array of infinite parent-child categories array ( 'id' => '134',&nb

5.

php recursively traverses multi-dimensional arrays, merges duplicate values ​​and records the number of repetitions ## Introduction: php recursively traverses multi-dimensional arrays, merges duplicate values ​​and records the number of repetitions header ('Content-type: text/html; charset=utf-8');//The following is the original array $array = array( 0=>array( 0=>array( 'text' => 'Sports' ,

6.

MySQL performance optimization points I encountered

Introduction:MySQL performance optimization points I encountered Optimization point 1. Call the interface in foreach (which executes a SQL statement to query) Improvement: First collect the fields to be queried into an array, and then use in to call the interface once: /** * @brief formatted data (collect array fields in, and finally use in to query) * @param params original array * @param fields required

7.

array in php

Introduction: array_walk: array_walk() returns Boolean. If the callback function needs to act directly on the array, specify the first parameter of the callback function as a reference. Any changes to these cells will also change the original array itself. This function can obtain the key and value of the array at the same time. array_map: array_map() returns an array, which contains

8. array_column: Convert a multi-dimensional array into a key-value array

Introduction: array_column(array$input,$column_key,$index_key) The first parameter is the original array, the second parameter (multidimensional array key name) is the value of the new array, and the third parameter (Multidimensional array key name) is the key. The result is an array of key-value pairs $array = [['id' = 1,'name' = 'tom','age' = 18],['id' = 2,' name' = 'jack','age' = 1

[Related Q&A recommendations]:

javascript - Array splicing and deduplication! It may include the type [num]

java.util.Arrays.sort() array parameter passing. Why can the contents of the original array be modified?

c++ - Is there a fixed-length array container in STL, similar to a vector that limits the number of elements? Do not use the original array of c

Statement:
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