note 79176 added to function.array-splice

From: Date: Wed, 14 Nov 2007 12:42:43 +0000
Subject: note 79176 added to function.array-splice
Groups: php.notes 
Request: Send a blank email to php-notes+get-132271@lists.php.net to get a copy of this message
Enjoy in randoming a banner. example: <?php $arrBanners['credit'] = array( 'i dont want to include this banner' 'i will include this banner' ); $arrBanners['links'] = array( 'banner1' ,'banner2' ,'banner3' ); $arrNotForTop = array( 'credit' => array(0) ); ?> <?php // function: function randomBanner($arrBanners,$exclude = array()) { $banners = array(); foreach ($arrBanners as $page => $arrBlock) { if (array_key_exists($page,$exclude)) { foreach ($arrBlock as $key => $banner) { if (!array_key_exists($key,$exclude[$page])) array_push($banners,$banner); } continue; } if (!is_array($arrBlock)) { array_push($banners,$arrBlock); continue; } foreach ($arrBlock as $val) array_push($banners,$val); } $banners = array_unique($banners); shuffle($banners); return $banners[1]; } ?> Please donate to alx@inbox.lv paypal :D ---- Server IP: 195.222.16.153 Probable Submitter: 88.196.124.149 ---- Manual Page -- http://www.php.net/manual/en/function.array-splice.php Edit -- https://master.php.net/note/edit/79176 Del: integrated -- https://master.php.net/note/delete/79176/integrated Del: useless -- https://master.php.net/note/delete/79176/useless Del: bad code -- https://master.php.net/note/delete/79176/bad+code Del: spam -- https://master.php.net/note/delete/79176/spam Del: non-english -- https://master.php.net/note/delete/79176/non-english Del: in docs -- https://master.php.net/note/delete/79176/in+docs Del: other reasons-- https://master.php.net/note/delete/79176 Reject -- https://master.php.net/note/reject/79176 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132271) next »