In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "php array anywhere to insert elements and delete specific elements of the example", the article explained the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "php array anywhere insert elements and delete specific elements of the example" it!
As follows:
$ary = array (array ('tweets = > 1), array (' tweets = > 2), array ($ary = > 9)); $t = array_splice ($ary, 1)); print_r ($ary)
Console output:
$ary = array (array ('tween = > 1), array (' t = > 3), array ('t = > 2)
A brief introduction to the array_splice method, parameter 1 is the array to be operated, parameter 2 is the index value of the operation element, parameter 3 is the length, and parameter 4 is the element to be replaced. The effect of this method is to delete the coherent elements in the parameter one array with parameter two as the starting position, length parameter three, and then fill it with parameter four.
If the length is 0, the effect is equivalent to inserting the specified element at the specified index value.
If the length is 1, the effect is equivalent to removing the element of the index value.
$ary = array (array ('tweets = > 1)
Delete a specific element in the array
$arr1 = array (1 arr1 3, 5 key 7 var_dump 8); $key = array_search (3, $arr1); if ($key! = = false) {array_splice ($arr1, $key, 1);} var_dump ($arr1)
Output: array (1, 5, 7, 8)
Array_slice (array,start,length,preserve)
Start with the start element of the array and return the rest of the array
$a=array ("red", "green", "blue", "yellow", "brown"); print_r (array_slice ($aMagne2))
Output array ("blue", "yellow", "brown")
Array_push
Array_push-pushes one or more units into the end of the array (stack)
Description
Int array_push (array & array, mixed var [, mixed...])
Array_push () treats array as a stack and pushes the passed variables into the end of the array. The length of the array will increase according to the number of variables on the stack.
Thank you for your reading, the above is the content of "insert elements and delete instances of specific elements anywhere in the php array". After the study of this article, I believe you have a deeper understanding of the problem of inserting elements and deleting instances of specific elements anywhere in the php array, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.