[DOC-CVS] [doc-en] master: array-merge.xml Amend the code examples (#5621)
[email protected] (Mikhail Alferov via GitHub) Fri, 24 Jul 2026 21:47:12 +0000
| Newsgroups | php.doc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: Mikhail Alferov (mmalferov)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2026-07-24T22:47:10+01:00
Commit: https://github.com/php/doc-en/commit/52209b319aabbecad59f887b6dff3fb15156f1ff
Raw diff: https://github.com/php/doc-en/commit/52209b319aabbecad59f887b6dff3fb15156f1ff.diff
array-merge.xml Amend the code examples (#5621)
Changed paths:
M reference/array/functions/array-merge.xml
Diff:
diff --git a/reference/array/functions/array-merge.xml b/reference/array/functions/array-merge.xml
index b9e3da1c0b37..99f4d2f36009 100644
--- a/reference/array/functions/array-merge.xml
+++ b/reference/array/functions/array-merge.xml
@@ -84,11 +84,13 @@
<programlisting role="php">
<![CDATA[
<?php
-$array1 = array("color" => "red", 2, 4);
-$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
+
+$array1 = ["color" => "red", 2, 4];
+$array2 = ["a", "b", "color" => "green", "shape" => "trapezoid", 4];
+
$result = array_merge($array1, $array2);
+
print_r($result);
-?>
]]>
</programlisting>
&example.outputs;
@@ -114,11 +116,13 @@ Array
<programlisting role="php">
<![CDATA[
<?php
-$array1 = array();
-$array2 = array(1 => "data");
+
+$array1 = [];
+$array2 = [1 => "data"];
+
$result = array_merge($array1, $array2);
+
print_r($result);
-?>
]]>
</programlisting>
<para>
@@ -141,11 +145,13 @@ Array
<programlisting role="php">
<![CDATA[
<?php
-$array1 = array(0 => 'zero_a', 2 => 'two_a', 3 => 'three_a');
-$array2 = array(1 => 'one_b', 3 => 'three_b', 4 => 'four_b');
+
+$array1 = [0 => 'zero_a', 2 => 'two_a', 3 => 'three_a'];
+$array2 = [1 => 'one_b', 3 => 'three_b', 4 => 'four_b'];
+
$result = $array1 + $array2;
+
var_dump($result);
-?>
]]>
</programlisting>
<para>
@@ -168,31 +174,6 @@ array(5) {
[4]=>
string(6) "four_b"
}
-]]>
- </screen>
- </example>
- </para>
- <para>
- <example>
- <title><function>array_merge</function> with non-array types</title>
- <programlisting role="php">
-<![CDATA[
-<?php
-$beginning = 'foo';
-$end = array(1 => 'bar');
-$result = array_merge((array) $beginning, (array) $end);
-print_r($result);
-?>
-]]>
- </programlisting>
- &example.outputs;
- <screen role="php">
-<![CDATA[
-Array
-(
- [0] => foo
- [1] => bar
-)
]]>
</screen>
</example>