com doc/ja: Add final example includes all variations of type casting and overwriting: language/types/array.xml
| From: | Yoshinari Takaoka | Date: | Tue, 23 Feb 2021 12:51:51 +0000 |
| Subject: | com doc/ja: Add final example includes all variations of type casting and overwriting: language/types/array.xml | ||
| Groups: | php.doc.ja | ||
| Request: | Send a blank email to doc-ja+get-6214@lists.php.net to get a copy of this message | ||
Commit: 26856cc71211ffe0a22050dc7c19e16db8d7ec96
Author: Yoshinari Takaoka <mumumu@mumumu.org> Tue, 23 Feb 2021 21:51:51 +0900
Parents: af35b78ad22514d2d7d0479dd41d666afec0c574
Branches: master
Link: http://git.php.net/?p=doc/ja.git;a=commitdiff;h=26856cc71211ffe0a22050dc7c19e16db8d7ec96
Log:
Add final example includes all variations of type casting and overwriting
Closes GH-450.
Changed paths:
M language/types/array.xml
Diff:
diff --git a/language/types/array.xml b/language/types/array.xml
index 132f273973..57f12e91ce 100644
--- a/language/types/array.xml
+++ b/language/types/array.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: 3ba291b86ab677a291807caaf69898b4a3bd11e1 Maintainer: takagi Status: ready
-->
+<!-- EN-Revision: 529359031bc69c5f635a459ae3891df4b8dc8df9 Maintainer: takagi Status: ready
-->
<!-- CREDITS: hirokawa,shimooka,mumumu -->
<sect1 xml:id="language.types.array">
<title>配列</title>
@@ -275,6 +275,53 @@ array(4) {
<literal>6</literal> だからです。
</para>
</example>
+
+ <example>
+ <title>複雑な型のキャストと上書きの例</title>
+ <para>
+
以下の例は、型のキャストされた時と、要素が上書きされる時の全ての場合を示しています。
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$array = array(
+ 1 => "a",
+ "1" => "b", // 値 "a" は "b"
で上書きされます。
+ 1.5 => "c", // 値 "b" は "c" で上書きされます。
+ -1 => 'd',
+ "01" => "e",
+ true => "f", // 値 "c" は "f" で上書きされます。
+ false => 'g',
+ '' => 'h',
+ null => 'i', // 値 "h" は "i" で上書きされます。
+ 'j', // 値 "j" はキー 2
が割り当てられます。なぜならこれより前の最大の整数のキーは1だからです。
+ 2 => 'k', // 値 "j" は "k" で上書きされます。
+);
+
+var_dump($array);
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+array(6) {
+ [1]=>
+ string(1) "f"
+ [-1]=>
+ string(1) "d"
+ ["01"]=>
+ string(1) "e"
+ [0]=>
+ string(1) "g"
+ [""]=>
+ string(1) "i"
+ [2]=>
+ string(1) "k"
+}
+]]>
+ </screen>
+ </example>
</sect3>
<sect3 xml:id="language.types.array.syntax.accessing">