rfc:array_find

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:array_find [2024/05/01 19:28] joshrfc:array_find [2024/06/01 11:23] (current) – Status: Implemented josh
Line 3: Line 3:
   * Date: 2024-04-07   * Date: 2024-04-07
   * Author: Joshua Rüsweg, josh@php.net   * Author: Joshua Rüsweg, josh@php.net
-  * Status: Under Discussion+  * Status: Implemented
   * First Published at: https://wiki.php.net/rfc/array_find   * First Published at: https://wiki.php.net/rfc/array_find
 +  * Discussion: https://externals.io/message/123015
 +  * Implementation: https://github.com/php/php-src/pull/14108
  
 ===== Introduction ===== ===== Introduction =====
Line 40: Line 42:
 <php>callable $callback</php> <php>callable $callback</php>
  
-The callback function to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns true, the value is returned from <php>array_find</php> and the callback will not be called for further elements.+The callback function to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns <php>true</php>, the value is returned from <php>array_find</php> and the callback will not be called for further elements.
  
 === Return Value === === Return Value ===
Line 102: Line 104:
 <php>callable $callback</php> <php>callable $callback</php>
  
-The callback function to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns true, the key is returned from <php>array_find_key</php> and the callback will not be called for further elements.+The callback function to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns <php>true</php>, the key is returned from <php>array_find_key</php> and the callback will not be called for further elements.
  
 === Return Value === === Return Value ===
Line 164: Line 166:
 <php>callable $callback</php> <php>callable $callback</php>
  
-The callback function to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns true, true is returned from <php>array_any</php> and the callback will not be called for further elements.+The callback function to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns <php>true</php><php>true</php> is returned from <php>array_any</php> and the callback will not be called for further elements.
  
 === Return Value === === Return Value ===
  
-The function returns true, if there is at least one element for which <php>$callback</php> returns <php>true</php>. Otherwise the function returns <php>false</php>.+The function returns <php>true</php>, if there is at least one element for which <php>$callback</php> returns <php>true</php>. Otherwise the function returns <php>false</php>.
  
 === Examples === === Examples ===
Line 222: Line 224:
 <php>callable $callback</php> <php>callable $callback</php>
  
-The callback function to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns <php>false</php> on any elementthe entire function returns <php>false</php> and the callback will not be called for further elements.+The callback function to call to check each element. The first parameter contains the value, the second parameter contains the corresponding key. If this function returns <php>false</php>, <php>false</php> is returned from <php>array_all</php> and the callback will not be called for further elements.
  
 === Return Value === === Return Value ===
  
-The function returns true, if <php>$callback</php> returns for every entry <php>true</php>. Otherwise the function returns <php>false</php>.+The function returns <php>true</php>, if <php>$callback</php> returns <php>true</php> for all elements. Otherwise the function returns <php>false</php>.
  
 === Examples === === Examples ===
Line 298: Line 300:
  
 Each vote requires a 2/3 majority. Each vote requires a 2/3 majority.
 +
 +Voting started on 2024-05-15 and will end on 2024-05-29 15:00 UTC.
  
 ==== array_find()/array_find_key() ==== ==== array_find()/array_find_key() ====
  
-<doodle title="Add array_find() and array_find_key()?" auth="josh" voteType="single" closed="true">+<doodle title="Add array_find() and array_find_key()?" auth="josh" voteType="single" closed="false" closeon="2024-05-29T15:00:00Z">
    * Yes    * Yes
    * No    * No
Line 309: Line 313:
 ==== array_any()/array_all() ==== ==== array_any()/array_all() ====
  
-<doodle title="Add array_any() and array_all()?" auth="josh" voteType="single" closed="true">+<doodle title="Add array_any() and array_all()?" auth="josh" voteType="single" closed="false" closeon="2024-05-29T15:00:00Z">
    * Yes    * Yes
    * No    * No
Line 317: Line 321:
 ===== Implementation ===== ===== Implementation =====
  
-https://github.com/joshuaruesweg/php-src/commit/9f3fc252b92f534d498e5f1e6a463e15f45da208+https://github.com/php/php-src/pull/14108
  
  
rfc/array_find.1714591701.txt.gz · Last modified: 2024/05/01 19:28 by josh