From d03ff9a8cac31c0b23f6062ba7fc9191839a746e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Tue, 12 Nov 2024 21:42:01 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E8=8B=B1=E8=AA=9E=E7=89=88=E7=8A=B6?= =?UTF-8?q?=E6=85=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reference/array/functions/array-all.xml | 136 ++++++++++++++++++ reference/array/functions/array-any.xml | 137 ++++++++++++++++++ reference/array/functions/array-filter.xml | 5 +- reference/array/functions/array-find-key.xml | 144 +++++++++++++++++++ reference/array/functions/array-find.xml | 144 +++++++++++++++++++ 5 files changed, 564 insertions(+), 2 deletions(-) create mode 100644 reference/array/functions/array-all.xml create mode 100644 reference/array/functions/array-any.xml create mode 100644 reference/array/functions/array-find-key.xml create mode 100644 reference/array/functions/array-find.xml diff --git a/reference/array/functions/array-all.xml b/reference/array/functions/array-all.xml new file mode 100644 index 0000000000..3215691f9d --- /dev/null +++ b/reference/array/functions/array-all.xml @@ -0,0 +1,136 @@ + + + + + + + array_all + Checks if all &array; elements satisfy a callback function + + + + &reftitle.description; + + mixedarray_all + arrayarray + callablecallback + + + array_all returns &true;, if the given + callback returns &true; for all elements. + Otherwise the function returns &false;. + + + + + &reftitle.parameters; + + + array + + + The &array; that should be searched. + + + + + callback + + + The callback function to call to check each element, which must be + + boolcallback + mixedvalue + mixedkey + + If this function returns &false;, &false; is returned from + array_all and the callback will not be called for + further elements. + + + + + + + + &reftitle.returnvalues; + + The function returns &true;, if callback returns + &true; for all elements. Otherwise the function returns &false;. + + + + + &reftitle.examples; + + <function>array_all</function> example + + 'dog', + 'b' => 'cat', + 'c' => 'cow', + 'd' => 'duck', + 'e' => 'goose', + 'f' => 'elephant' +]; + +// Check, if all animal names are shorter than 12 letters. +var_dump(array_all($array, function (string $value) { + return strlen($value) < 12; +})); + +// Check, if all animal names are longer than 5 letters. +var_dump(array_all($array, function (string $value) { + return strlen($value) > 5; +})); + +// Check, if all array keys are strings. +var_dump(array_all($array, function (string $value, $key) { + return is_string($key); +})); +?> +]]> + + &example.outputs; + + + + + + + + &reftitle.seealso; + + array_any + array_filter + array_find + array_find_key + + + + diff --git a/reference/array/functions/array-any.xml b/reference/array/functions/array-any.xml new file mode 100644 index 0000000000..a3e2410256 --- /dev/null +++ b/reference/array/functions/array-any.xml @@ -0,0 +1,137 @@ + + + + + + + array_any + Checks if at least one &array; element satisfies a callback function + + + + &reftitle.description; + + mixedarray_any + arrayarray + callablecallback + + + array_any returns &true;, if the given + callback returns &true; for any element. + Otherwise the function returns &false;. + + + + + &reftitle.parameters; + + + array + + + The &array; that should be searched. + + + + + callback + + + The callback function to call to check each element, which must be + + boolcallback + mixedvalue + mixedkey + + If this function returns &true;, &true; is returned from + array_any and the callback will not be called for + further elements. + + + + + + + + &reftitle.returnvalues; + + The function returns &true;, if there is at least one element for which + callback returns &true;. Otherwise the function + returns &false;. + + + + + &reftitle.examples; + + <function>array_any</function> example + + 'dog', + 'b' => 'cat', + 'c' => 'cow', + 'd' => 'duck', + 'e' => 'goose', + 'f' => 'elephant' +]; + +// Check, if any animal name is longer than 5 letters. +var_dump(array_any($array, function (string $value) { + return strlen($value) > 5; +})); + +// Check, if any animal name is shorter than 3 letters. +var_dump(array_any($array, function (string $value) { + return strlen($value) < 3; +})); + +// Check, if any array key is not a string. +var_dump(array_any($array, function (string $value, $key) { + return !is_string($key); +})); +?> +]]> + + &example.outputs; + + + + + + + + &reftitle.seealso; + + array_all + array_filter + array_find + array_find_key + + + + diff --git a/reference/array/functions/array-filter.xml b/reference/array/functions/array-filter.xml index 1f1a9f8991..a96eb238a9 100644 --- a/reference/array/functions/array-filter.xml +++ b/reference/array/functions/array-filter.xml @@ -9,7 +9,7 @@ コールバック関数を使用して、配列の要素をフィルタリングする - + &reftitle.description; @@ -259,9 +259,10 @@ array(2) { array_intersect + array_find + array_any array_map array_reduce - array_walk diff --git a/reference/array/functions/array-find-key.xml b/reference/array/functions/array-find-key.xml new file mode 100644 index 0000000000..13a70bde96 --- /dev/null +++ b/reference/array/functions/array-find-key.xml @@ -0,0 +1,144 @@ + + + + + + + array_find_key + Returns the key of the first element satisfying a callback function + + + + &reftitle.description; + + mixedarray_find_key + arrayarray + callablecallback + + + array_find_key returns the key of the first element of an + &array; for which the given callback returns &true;. + If no matching element is found the function returns &null;. + + + + + &reftitle.parameters; + + + array + + + The &array; that should be searched. + + + + + callback + + + The callback function to call to check each element, which must be + + boolcallback + mixedvalue + mixedkey + + If this function returns &true;, the key is returned from + array_find_key and the callback will not be called + for further elements. + + + + + + + + &reftitle.returnvalues; + + The function returns the key of the first element for which the + callback returns &true;. If no matching element is + found the function returns &null;. + + + + + &reftitle.examples; + + <function>array_find_key</function> example + + 'dog', + 'b' => 'cat', + 'c' => 'cow', + 'd' => 'duck', + 'e' => 'goose', + 'f' => 'elephant' +]; + +// Find the first animal with a name longer than 4 characters. +var_dump(array_find_key($array, function (string $value) { + return strlen($value) > 4; +})); + +// Find the first animal whose name begins with f. +var_dump(array_find_key($array, function (string $value) { + return str_starts_with($value, 'f'); +})); + +// Find the first animal where the array key is the first symbol of the animal. +var_dump(array_find_key($array, function (string $value, $key) { + return $value[0] === $key; +})); + +// Find the first animal where the array key matching a RegEx. +var_dump(array_find_key($array, function ($value, $key) { + return preg_match('/^([a-f])$/', $key); +})); +?> +]]> + + &example.outputs; + + + + + + + + &reftitle.seealso; + + array_find + array_all + array_any + array_filter + array_reduce + + + + diff --git a/reference/array/functions/array-find.xml b/reference/array/functions/array-find.xml new file mode 100644 index 0000000000..60e05bacc7 --- /dev/null +++ b/reference/array/functions/array-find.xml @@ -0,0 +1,144 @@ + + + + + + + array_find + Returns the first element satisfying a callback function + + + + &reftitle.description; + + mixedarray_find + arrayarray + callablecallback + + + array_find returns the value of the first element of an + &array; for which the given callback returns &true;. + If no matching element is found the function returns &null;. + + + + + &reftitle.parameters; + + + array + + + The &array; that should be searched. + + + + + callback + + + The callback function to call to check each element, which must be + + boolcallback + mixedvalue + mixedkey + + If this function returns &true;, the value is returned from + array_find and the callback will not be called for + further elements. + + + + + + + + &reftitle.returnvalues; + + The function returns the value of the first element for which the + callback returns &true;. If no matching element is + found the function returns &null;. + + + + + &reftitle.examples; + + <function>array_find</function> example + + 'dog', + 'b' => 'cat', + 'c' => 'cow', + 'd' => 'duck', + 'e' => 'goose', + 'f' => 'elephant' +]; + +// Find the first animal with a name longer than 4 characters. +var_dump(array_find($array, function (string $value) { + return strlen($value) > 4; +})); + +// Find the first animal whose name begins with f. +var_dump(array_find($array, function (string $value) { + return str_starts_with($value, 'f'); +})); + +// Find the first animal where the array key is the first symbol of the animal. +var_dump(array_find($array, function (string $value, $key) { + return $value[0] === $key; +})); + +// Find the first animal where the array key matching a RegEx. +var_dump(array_find($array, function ($value, $key) { + return preg_match('/^([a-f])$/', $key); +})); +?> +]]> + + &example.outputs; + + + + + + + + &reftitle.seealso; + + array_find_key + array_all + array_any + array_filter + array_reduce + + + + From b7212d5ec6189ebf53920a0c24688c2e54a14ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Tue, 12 Nov 2024 22:36:52 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[PHP=208.4]=20`array=5Fall`,=20`array=5Fany?= =?UTF-8?q?`,=20`array-find`,=20`array=5Ffind=5Fkey`=20=E3=81=AE=E7=BF=BB?= =?UTF-8?q?=E8=A8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reference/array/functions/array-all.xml | 30 ++++++++--------- reference/array/functions/array-any.xml | 32 +++++++++--------- reference/array/functions/array-find-key.xml | 34 ++++++++++---------- reference/array/functions/array-find.xml | 34 ++++++++++---------- 4 files changed, 65 insertions(+), 65 deletions(-) diff --git a/reference/array/functions/array-all.xml b/reference/array/functions/array-all.xml index 3215691f9d..e3329d12cc 100644 --- a/reference/array/functions/array-all.xml +++ b/reference/array/functions/array-all.xml @@ -5,7 +5,7 @@ array_all - Checks if all &array; elements satisfy a callback function + &array; のすべての要素がコールバック関数を満たすかどうかを調べる @@ -16,9 +16,9 @@ callablecallback - array_all returns &true;, if the given - callback returns &true; for all elements. - Otherwise the function returns &false;. + array_all は、指定された callback が + すべての要素に対して &true; を返す場合 &true; を返します。 + そうでない場合 &false; を返します。 @@ -29,7 +29,7 @@ array - The &array; that should be searched. + 検索する &array;。 @@ -37,15 +37,15 @@ callback - The callback function to call to check each element, which must be + 各要素を調べるコールバック関数。シグネチャは次の通りです: boolcallback mixedvalue mixedkey - If this function returns &false;, &false; is returned from - array_all and the callback will not be called for - further elements. + この関数が &false; を返すと、 + array_all から &false; が返され、 + 以降の要素に対してはコールバックは呼び出されません。 @@ -55,15 +55,15 @@ &reftitle.returnvalues; - The function returns &true;, if callback returns - &true; for all elements. Otherwise the function returns &false;. + callback がすべての要素に対して &true; を返す場合、 + この関数は &true; を返します。そうでない場合 &false; を返します。 &reftitle.examples; - <function>array_all</function> example + <function>array_all</function> の例 'elephant' ]; -// Check, if all animal names are shorter than 12 letters. +// すべての動物名が12文字未満かどうかをチェックします。 var_dump(array_all($array, function (string $value) { return strlen($value) < 12; })); -// Check, if all animal names are longer than 5 letters. +// すべての動物名が5文字より長いかどうかをチェックします。 var_dump(array_all($array, function (string $value) { return strlen($value) > 5; })); -// Check, if all array keys are strings. +// すべての配列キーが文字列かどうかをチェックします。 var_dump(array_all($array, function (string $value, $key) { return is_string($key); })); diff --git a/reference/array/functions/array-any.xml b/reference/array/functions/array-any.xml index a3e2410256..9d9184b52e 100644 --- a/reference/array/functions/array-any.xml +++ b/reference/array/functions/array-any.xml @@ -5,7 +5,7 @@ array_any - Checks if at least one &array; element satisfies a callback function + &array; のいずれかの要素がコールバック関数を満たすかどうかを調べる @@ -16,9 +16,9 @@ callablecallback - array_any returns &true;, if the given - callback returns &true; for any element. - Otherwise the function returns &false;. + array_any は、指定されたcallback が + いずれかの要素に対して &true; を返す場合 &true; を返します。 + そうでない場合 &false; を返します。 @@ -29,7 +29,7 @@ array - The &array; that should be searched. + 検索する &array;。 @@ -37,15 +37,15 @@ callback - The callback function to call to check each element, which must be + 各要素を調べるコールバック関数。シグネチャは次の通りです: boolcallback mixedvalue mixedkey - If this function returns &true;, &true; is returned from - array_any and the callback will not be called for - further elements. + この関数が &true; を返すと、 + array_any から &true; が返され、 + 以降の要素に対してはコールバックは呼び出されません。 @@ -55,16 +55,16 @@ &reftitle.returnvalues; - The function returns &true;, if there is at least one element for which - callback returns &true;. Otherwise the function - returns &false;. + この関数は、callback が &true; を返す要素が + 少なくとも1つある場合、&true; を返します。 + そうでない場合 &false; を返します。 &reftitle.examples; - <function>array_any</function> example + <function>array_any</function> の例 'elephant' ]; -// Check, if any animal name is longer than 5 letters. +// いずれかの動物名が5文字より長いかどうかをチェックします。 var_dump(array_any($array, function (string $value) { return strlen($value) > 5; })); -// Check, if any animal name is shorter than 3 letters. +// いずれかの動物名が3文字より短いかどうかをチェックします。 var_dump(array_any($array, function (string $value) { return strlen($value) < 3; })); -// Check, if any array key is not a string. +// 配列キーに文字列でないものがあるかどうかをチェックします。 var_dump(array_any($array, function (string $value, $key) { return !is_string($key); })); diff --git a/reference/array/functions/array-find-key.xml b/reference/array/functions/array-find-key.xml index 13a70bde96..18c25891f3 100644 --- a/reference/array/functions/array-find-key.xml +++ b/reference/array/functions/array-find-key.xml @@ -5,7 +5,7 @@ array_find_key - Returns the key of the first element satisfying a callback function + コールバック関数を満たす最初の要素のキーを返す @@ -16,9 +16,9 @@ callablecallback - array_find_key returns the key of the first element of an - &array; for which the given callback returns &true;. - If no matching element is found the function returns &null;. + array_find_key は、指定された + callback が &true; を返す &array; の最初の要素のキーを返します。 + 見つからない場合 &null; を返します。 @@ -29,7 +29,7 @@ array - The &array; that should be searched. + 検索する &array;。 @@ -37,15 +37,15 @@ callback - The callback function to call to check each element, which must be + 各要素を調べるコールバック関数。シグネチャは次の通りです: boolcallback mixedvalue mixedkey - If this function returns &true;, the key is returned from - array_find_key and the callback will not be called - for further elements. + この関数が &true; を返すと、 + その要素のキーが array_find_key から返され、 + 以降の要素に対してはコールバックは呼び出されません。 @@ -55,16 +55,16 @@ &reftitle.returnvalues; - The function returns the key of the first element for which the - callback returns &true;. If no matching element is - found the function returns &null;. + callback が &true; を返す最初の要素のキーを返します。 + 一致する要素が見つからない場合、 + &null; を返します。 &reftitle.examples; - <function>array_find_key</function> example + <function>array_find_key</function> の例 'elephant' ]; -// Find the first animal with a name longer than 4 characters. +// 名前が4文字より長い最初の動物を探します。 var_dump(array_find_key($array, function (string $value) { return strlen($value) > 4; })); -// Find the first animal whose name begins with f. +// 名前がfで始まる最初の動物を探します。 var_dump(array_find_key($array, function (string $value) { return str_starts_with($value, 'f'); })); -// Find the first animal where the array key is the first symbol of the animal. +// 配列キーが動物の最初の文字と一致する最初の動物を探します。 var_dump(array_find_key($array, function (string $value, $key) { return $value[0] === $key; })); -// Find the first animal where the array key matching a RegEx. +// 配列キーが正規表現にマッチする最初の動物を探します。 var_dump(array_find_key($array, function ($value, $key) { return preg_match('/^([a-f])$/', $key); })); diff --git a/reference/array/functions/array-find.xml b/reference/array/functions/array-find.xml index 60e05bacc7..edf9d50fe6 100644 --- a/reference/array/functions/array-find.xml +++ b/reference/array/functions/array-find.xml @@ -5,7 +5,7 @@ array_find - Returns the first element satisfying a callback function + コールバック関数を満たす最初の要素を返す @@ -16,9 +16,9 @@ callablecallback - array_find returns the value of the first element of an - &array; for which the given callback returns &true;. - If no matching element is found the function returns &null;. + array_find は、指定された + callback が &true; を返す &array; の最初の要素を返します。 + 見つからない場合 &null; を返します。 @@ -29,7 +29,7 @@ array - The &array; that should be searched. + 検索する &array;。 @@ -37,15 +37,15 @@ callback - The callback function to call to check each element, which must be + 各要素を調べるコールバック関数。シグネチャは次の通りです: boolcallback mixedvalue mixedkey - If this function returns &true;, the value is returned from - array_find and the callback will not be called for - further elements. + この関数が &true; を返すと、 + その要素が array_find から返され、 + 以降の要素に対してはコールバックは呼び出されません。 @@ -55,16 +55,16 @@ &reftitle.returnvalues; - The function returns the value of the first element for which the - callback returns &true;. If no matching element is - found the function returns &null;. + callback が &true; を返す最初の要素を返します。 + 一致する要素が見つからない場合、 + &null; を返します。 &reftitle.examples; - <function>array_find</function> example + <function>array_find</function> の例 'elephant' ]; -// Find the first animal with a name longer than 4 characters. +// 名前が4文字より長い最初の動物を探します。 var_dump(array_find($array, function (string $value) { return strlen($value) > 4; })); -// Find the first animal whose name begins with f. +// 名前がfで始まる最初の動物を探します。 var_dump(array_find($array, function (string $value) { return str_starts_with($value, 'f'); })); -// Find the first animal where the array key is the first symbol of the animal. +// キーが動物の名前の最初の文字と一致する最初の動物を探します。 var_dump(array_find($array, function (string $value, $key) { return $value[0] === $key; })); -// Find the first animal where the array key matching a RegEx. +// キーが正規表現にマッチする最初の動物を探します。 var_dump(array_find($array, function ($value, $key) { return preg_match('/^([a-f])$/', $key); }));