note 51322 added to function.preg-split

From: Date: Sun, 27 Mar 2005 11:32:49 +0000
Subject: note 51322 added to function.preg-split
Groups: php.notes 
Request: Send a blank email to php-notes+get-87054@lists.php.net to get a copy of this message
Here's a simple script i made. It uses preg_split, explode and some array_reverse functions to print, the defined text, backwards. I'm sure its not the easiest way to do this but it works: <?php $text = 'Hello, I am called Joe Bloggs'; $print1 = array_reverse(explode(' ', $text)); $count = count($print1); $i = 0; while ($i <= $count) { $chars = preg_split('//', $print1[$i], -1, PREG_SPLIT_NO_EMPTY); $print = array_reverse($chars); $count2 = count($print); $i++; $b = 0; while ($b <= $count2) { if ($b == $count2) { echo "\r\r"; } echo $print[$b]; $b++; } } ?> when run, page reads : "sggolB eoJ dellac ma I ,olleH" ---- Manual Page -- http://www.php.net/manual/en/function.preg-split.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51322 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51322&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51322&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51322&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51322&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51322&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51322&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87054) next »