search
Home类库下载PHP类库The difference between array_merge and array+array in php

array_merge discards the original numeric key, retains the key in string form, and then forms a new array. No matter whether the key name

is the same, it will not be merged, unless the key name and value are the same at the same time and must be in string form. keys are merged. The thing about array+array is that no matter what your situation is, it will only put the data of the previous array into the newly generated array first, and then see if the second array is larger than the first array. If there are many, more will be added in. It only counts the number, but in this case it will be added in:


$a = array('d'=>'aass','e'=>'adsdfd', 'asd'=>'asdsdd','ddfg'=>'dssdf');
$b = array('d'=>'adddd','adsdfd','asdfsddddd','d'=>'aass' );
$d = $a + $b;

$e = array_merge($a,$b);

var_dump($d);
var_dump($e);Print: array 'd' => string'aass ' (length=4) 'e' => string'adsdfd'

(length=6) 'asd' => string'asdsdd' (length=6) 'ddfg' => string'dssdf' (length=5) 0

=> string'adsdfd' (length=6) 1 => string'asdfsddddd' (length=10)array 'd' => string'aass' (length=4) 'e' => string'adsdfd'

(length=6) 'asd' => string'asdsdd' (length=6) 'ddfg' => string'dssdf' (length=5) 0

=> string'adsdfd' (length=6) 1 => string'asdfsddddd' (length=10)

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

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.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment