note 58322 added to function.array-walk

From: Date: Mon, 31 Oct 2005 14:07:24 +0000
Subject: note 58322 added to function.array-walk
Groups: php.notes 
Request: Send a blank email to php-notes+get-97881@lists.php.net to get a copy of this message
This is a short way to concatenate a string to each element of an array: $arr=array(1,2,3,4,5,6,7,8,9,0); $str=' test'; // must not include ' or " ... array_walk($arr,create_function('&$elem','$elem .= "' . $str . '";')); var_export($arr); The output is: array ( 0 => '1 test', 1 => '2 test', 2 => '3 test', 3 => '4 test', 4 => '5 test', 5 => '6 test', 6 => '7 test', 7 => '8 test', 8 => '9 test', 9 => '0 test', ) ---- Manual Page -- http://www.php.net/manual/en/function.array-walk.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58322 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58322&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58322&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58322&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58322&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58322&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58322&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58322&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58322&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97881) next »