11<?xml version =" 1.0" encoding =" utf-8" ?>
22<!-- $Revision$ -->
3- <!-- EN-Revision: 2e60c5134e7a847c99f81eb3f7ecee1f5efeeace Maintainer: hirokawa Status: ready -->
3+ <!-- EN-Revision: 52209b319aabbecad59f887b6dff3fb15156f1ff Maintainer: hirokawa Status: ready -->
44<!-- CREDITS: shimooka,mumumu -->
55<refentry xml : id =" function.array-merge" xmlns =" http://docbook.org/ns/docbook" >
66 <refnamediv >
8383 <programlisting role =" php" >
8484<![CDATA[
8585<?php
86- $array1 = array("color" => "red", 2, 4);
87- $array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
86+
87+ $array1 = ["color" => "red", 2, 4];
88+ $array2 = ["a", "b", "color" => "green", "shape" => "trapezoid", 4];
89+
8890$result = array_merge($array1, $array2);
91+
8992print_r($result);
90- ?>
9193]]>
9294 </programlisting >
9395 &example.outputs;
@@ -113,11 +115,13 @@ Array
113115 <programlisting role =" php" >
114116<![CDATA[
115117<?php
116- $array1 = array();
117- $array2 = array(1 => "data");
118+
119+ $array1 = [];
120+ $array2 = [1 => "data"];
121+
118122$result = array_merge($array1, $array2);
123+
119124print_r($result);
120- ?>
121125]]>
122126 </programlisting >
123127 <para >
@@ -140,11 +144,13 @@ Array
140144 <programlisting role =" php" >
141145<![CDATA[
142146<?php
143- $array1 = array(0 => 'zero_a', 2 => 'two_a', 3 => 'three_a');
144- $array2 = array(1 => 'one_b', 3 => 'three_b', 4 => 'four_b');
147+
148+ $array1 = [0 => 'zero_a', 2 => 'two_a', 3 => 'three_a'];
149+ $array2 = [1 => 'one_b', 3 => 'three_b', 4 => 'four_b'];
150+
145151$result = $array1 + $array2;
152+
146153var_dump($result);
147- ?>
148154]]>
149155 </programlisting >
150156 <para >
@@ -166,31 +172,6 @@ array(5) {
166172 [4]=>
167173 string(6) "four_b"
168174}
169- ]]>
170- </screen >
171- </example >
172- </para >
173- <para >
174- <example >
175- <title ><function >array_merge</function > で配列以外の型を扱う例</title >
176- <programlisting role =" php" >
177- <![CDATA[
178- <?php
179- $beginning = 'foo';
180- $end = array(1 => 'bar');
181- $result = array_merge((array) $beginning, (array) $end);
182- print_r($result);
183- ?>
184- ]]>
185- </programlisting >
186- &example.outputs;
187- <screen role =" php" >
188- <![CDATA[
189- Array
190- (
191- [0] => foo
192- [1] => bar
193- )
194175]]>
195176 </screen >
196177 </example >
0 commit comments