note 58862 added to function.array-walk

From: Date: Fri, 18 Nov 2005 03:53:34 +0000
Subject: note 58862 added to function.array-walk
Groups: php.notes 
Request: Send a blank email to php-notes+get-98733@lists.php.net to get a copy of this message
If anyone is interested to implement the array_walk functionality to a string. I've made this handy function. Note that this can be easily extended for any type of purpose. I've used this to convert from a string of bytes to a hex string then back from hex to a byte string. <?php function string_walk($string,$funcname) { for($i=0;$i<strlen($string);$i++) { call_user_func($funcname,$string{$i}); } } function yourFunc($val) { echo $val.' '; } string_walk('interesting','yourFunc'); //ouput: i n t e r e s t i n g ?> ---- Manual Page -- http://www.php.net/manual/en/function.array-walk.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58862 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58862&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58862&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58862&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58862&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58862&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58862&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58862&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58862&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98733) next »