note 127018 added to function.next

From: Date: Thu, 28 Apr 2022 09:28:21 +0000
Subject: note 127018 added to function.next
Groups: php.notes 
Request: Send a blank email to php-notes+get-218328@lists.php.net to get a copy of this message
This is the best example of using next in a loop <?php $array = array( 'fruit1' => 'apple', 'fruit2' => 'orange', 'fruit3' => 'grape', 'fruit4' => 'apple', 'fruit5' => 'apple'); // this cycle echoes all associative array // key where value equals "apple" reset($array); // prepare array for cycle while ($fruit_name = current($array)) { if ($fruit_name == 'apple') { echo key($array), "\n"; } next($array); } reset($array); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.159.162 (proxied: 212.90.59.36) ---- Manual Page -- https://php.net/manual/en/function.next.php Edit -- https://main.php.net/note/edit/127018 Del: integrated -- https://main.php.net/note/delete/127018/integrated Del: useless -- https://main.php.net/note/delete/127018/useless Del: bad code -- https://main.php.net/note/delete/127018/bad+code Del: spam -- https://main.php.net/note/delete/127018/spam Del: non-english -- https://main.php.net/note/delete/127018/non-english Del: in docs -- https://main.php.net/note/delete/127018/in+docs Del: other reasons-- https://main.php.net/note/delete/127018 Reject -- https://main.php.net/note/reject/127018 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218328) next »