Skip to content

Commit d03ff9a

Browse files
英語版状態
1 parent 7840133 commit d03ff9a

File tree

5 files changed

+564
-2
lines changed

5 files changed

+564
-2
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
<!-- EN-Revision: 596c11440dc232b8ed1836d7e3afe2ed5b225a7b Maintainer: KentarouTakeda Status: ready -->
4+
<!-- CREDITS: KentarouTakeda -->
5+
<refentry xml:id="function.array-all" xmlns="http://docbook.org/ns/docbook">
6+
<refnamediv>
7+
<refname>array_all</refname>
8+
<refpurpose>Checks if all &array; elements satisfy a callback function</refpurpose>
9+
</refnamediv>
10+
11+
<refsect1 role="description">
12+
&reftitle.description;
13+
<methodsynopsis>
14+
<type>mixed</type><methodname>array_all</methodname>
15+
<methodparam><type>array</type><parameter>array</parameter></methodparam>
16+
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
17+
</methodsynopsis>
18+
<simpara>
19+
<function>array_all</function> returns &true;, if the given
20+
<parameter>callback</parameter> returns &true; for all elements.
21+
Otherwise the function returns &false;.
22+
</simpara>
23+
</refsect1>
24+
25+
<refsect1 role="parameters">
26+
&reftitle.parameters;
27+
<variablelist>
28+
<varlistentry>
29+
<term><parameter>array</parameter></term>
30+
<listitem>
31+
<simpara>
32+
The &array; that should be searched.
33+
</simpara>
34+
</listitem>
35+
</varlistentry>
36+
<varlistentry>
37+
<term><parameter>callback</parameter></term>
38+
<listitem>
39+
<para>
40+
The callback function to call to check each element, which must be
41+
<methodsynopsis>
42+
<type>bool</type><methodname><replaceable>callback</replaceable></methodname>
43+
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
44+
<methodparam><type>mixed</type><parameter>key</parameter></methodparam>
45+
</methodsynopsis>
46+
If this function returns &false;, &false; is returned from
47+
<function>array_all</function> and the callback will not be called for
48+
further elements.
49+
</para>
50+
</listitem>
51+
</varlistentry>
52+
</variablelist>
53+
</refsect1>
54+
55+
<refsect1 role="returnvalues">
56+
&reftitle.returnvalues;
57+
<simpara>
58+
The function returns &true;, if <parameter>callback</parameter> returns
59+
&true; for all elements. Otherwise the function returns &false;.
60+
</simpara>
61+
</refsect1>
62+
63+
<refsect1 role="examples">
64+
&reftitle.examples;
65+
<example>
66+
<title><function>array_all</function> example</title>
67+
<programlisting role="php">
68+
<![CDATA[
69+
<?php
70+
$array = [
71+
'a' => 'dog',
72+
'b' => 'cat',
73+
'c' => 'cow',
74+
'd' => 'duck',
75+
'e' => 'goose',
76+
'f' => 'elephant'
77+
];
78+
79+
// Check, if all animal names are shorter than 12 letters.
80+
var_dump(array_all($array, function (string $value) {
81+
return strlen($value) < 12;
82+
}));
83+
84+
// Check, if all animal names are longer than 5 letters.
85+
var_dump(array_all($array, function (string $value) {
86+
return strlen($value) > 5;
87+
}));
88+
89+
// Check, if all array keys are strings.
90+
var_dump(array_all($array, function (string $value, $key) {
91+
return is_string($key);
92+
}));
93+
?>
94+
]]>
95+
</programlisting>
96+
&example.outputs;
97+
<screen>
98+
<![CDATA[
99+
bool(true)
100+
bool(false)
101+
bool(true)
102+
]]>
103+
</screen>
104+
</example>
105+
</refsect1>
106+
107+
<refsect1 role="seealso">
108+
&reftitle.seealso;
109+
<simplelist>
110+
<member><function>array_any</function></member>
111+
<member><function>array_filter</function></member>
112+
<member><function>array_find</function></member>
113+
<member><function>array_find_key</function></member>
114+
</simplelist>
115+
</refsect1>
116+
</refentry>
117+
<!-- Keep this comment at the end of the file
118+
Local variables:
119+
mode: sgml
120+
sgml-omittag:t
121+
sgml-shorttag:t
122+
sgml-minimize-attributes:nil
123+
sgml-always-quote-attributes:t
124+
sgml-indent-step:1
125+
sgml-indent-data:t
126+
indent-tabs-mode:nil
127+
sgml-parent-document:nil
128+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
129+
sgml-exposed-tags:nil
130+
sgml-local-catalogs:nil
131+
sgml-local-ecat-files:nil
132+
End:
133+
vim600: syn=xml fen fdm=syntax fdl=2 si
134+
vim: et tw=78 syn=sgml
135+
vi: ts=1 sw=1
136+
-->
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- $Revision$ -->
3+
<!-- EN-Revision: 596c11440dc232b8ed1836d7e3afe2ed5b225a7b Maintainer: KentarouTakeda Status: ready -->
4+
<!-- CREDITS: KentarouTakeda -->
5+
<refentry xml:id="function.array-any" xmlns="http://docbook.org/ns/docbook">
6+
<refnamediv>
7+
<refname>array_any</refname>
8+
<refpurpose>Checks if at least one &array; element satisfies a callback function</refpurpose>
9+
</refnamediv>
10+
11+
<refsect1 role="description">
12+
&reftitle.description;
13+
<methodsynopsis>
14+
<type>mixed</type><methodname>array_any</methodname>
15+
<methodparam><type>array</type><parameter>array</parameter></methodparam>
16+
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
17+
</methodsynopsis>
18+
<simpara>
19+
<function>array_any</function> returns &true;, if the given
20+
<parameter>callback</parameter> returns &true; for any element.
21+
Otherwise the function returns &false;.
22+
</simpara>
23+
</refsect1>
24+
25+
<refsect1 role="parameters">
26+
&reftitle.parameters;
27+
<variablelist>
28+
<varlistentry>
29+
<term><parameter>array</parameter></term>
30+
<listitem>
31+
<simpara>
32+
The &array; that should be searched.
33+
</simpara>
34+
</listitem>
35+
</varlistentry>
36+
<varlistentry>
37+
<term><parameter>callback</parameter></term>
38+
<listitem>
39+
<para>
40+
The callback function to call to check each element, which must be
41+
<methodsynopsis>
42+
<type>bool</type><methodname><replaceable>callback</replaceable></methodname>
43+
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
44+
<methodparam><type>mixed</type><parameter>key</parameter></methodparam>
45+
</methodsynopsis>
46+
If this function returns &true;, &true; is returned from
47+
<function>array_any</function> and the callback will not be called for
48+
further elements.
49+
</para>
50+
</listitem>
51+
</varlistentry>
52+
</variablelist>
53+
</refsect1>
54+
55+
<refsect1 role="returnvalues">
56+
&reftitle.returnvalues;
57+
<simpara>
58+
The function returns &true;, if there is at least one element for which
59+
<parameter>callback</parameter> returns &true;. Otherwise the function
60+
returns &false;.
61+
</simpara>
62+
</refsect1>
63+
64+
<refsect1 role="examples">
65+
&reftitle.examples;
66+
<example>
67+
<title><function>array_any</function> example</title>
68+
<programlisting role="php">
69+
<![CDATA[
70+
<?php
71+
$array = [
72+
'a' => 'dog',
73+
'b' => 'cat',
74+
'c' => 'cow',
75+
'd' => 'duck',
76+
'e' => 'goose',
77+
'f' => 'elephant'
78+
];
79+
80+
// Check, if any animal name is longer than 5 letters.
81+
var_dump(array_any($array, function (string $value) {
82+
return strlen($value) > 5;
83+
}));
84+
85+
// Check, if any animal name is shorter than 3 letters.
86+
var_dump(array_any($array, function (string $value) {
87+
return strlen($value) < 3;
88+
}));
89+
90+
// Check, if any array key is not a string.
91+
var_dump(array_any($array, function (string $value, $key) {
92+
return !is_string($key);
93+
}));
94+
?>
95+
]]>
96+
</programlisting>
97+
&example.outputs;
98+
<screen>
99+
<![CDATA[
100+
bool(true)
101+
bool(false)
102+
bool(false)
103+
]]>
104+
</screen>
105+
</example>
106+
</refsect1>
107+
108+
<refsect1 role="seealso">
109+
&reftitle.seealso;
110+
<simplelist>
111+
<member><function>array_all</function></member>
112+
<member><function>array_filter</function></member>
113+
<member><function>array_find</function></member>
114+
<member><function>array_find_key</function></member>
115+
</simplelist>
116+
</refsect1>
117+
</refentry>
118+
<!-- Keep this comment at the end of the file
119+
Local variables:
120+
mode: sgml
121+
sgml-omittag:t
122+
sgml-shorttag:t
123+
sgml-minimize-attributes:nil
124+
sgml-always-quote-attributes:t
125+
sgml-indent-step:1
126+
sgml-indent-data:t
127+
indent-tabs-mode:nil
128+
sgml-parent-document:nil
129+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
130+
sgml-exposed-tags:nil
131+
sgml-local-catalogs:nil
132+
sgml-local-ecat-files:nil
133+
End:
134+
vim600: syn=xml fen fdm=syntax fdl=2 si
135+
vim: et tw=78 syn=sgml
136+
vi: ts=1 sw=1
137+
-->

reference/array/functions/array-filter.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
コールバック関数を使用して、配列の要素をフィルタリングする
1010
</refpurpose>
1111
</refnamediv>
12-
12+
1313
<refsect1 role="description">
1414
&reftitle.description;
1515
<methodsynopsis>
@@ -259,9 +259,10 @@ array(2) {
259259
<para>
260260
<simplelist>
261261
<member><function>array_intersect</function></member>
262+
<member><function>array_find</function></member>
263+
<member><function>array_any</function></member>
262264
<member><function>array_map</function></member>
263265
<member><function>array_reduce</function></member>
264-
<member><function>array_walk</function></member>
265266
</simplelist>
266267
</para>
267268
</refsect1>

0 commit comments

Comments
 (0)