note 58039 added to function.explode

From: Date: Sat, 22 Oct 2005 01:27:05 +0000
Subject: note 58039 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-97397@lists.php.net to get a copy of this message
Correct me if I'm wrong, but I think this way of doing the explode_quote or explode2 function is much quicker if you always want to mark words by quotes and a space is the delimeter to break things on otherwise. Using php's built in functions usually makes things run a lot faster. <?php function explode_quotes($AString) { $words = wordwrap($AString,3); $exploded = explode("\n",$words); $exploded = str_replace(chr(26),' ',$exploded); return $exploded; } ?> I don't know what benchmark you are talking about for the other posts since they are never really described, but I just put a for loop around each one and ran the for loop 400000 times and here is the time difference between my explode_quotes and the first posted explode_quote Start 1: 1129947556 End 1: 1129947559 Total 1: 3 seconds Start 2: 1129947559 End 2: 1129947584 Total 2: 25 seconds Not very scientific, but the advantage is clear. Note, my email address is obfuscated by moving my left hand one key position to the right. ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58039 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58039&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58039&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58039&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58039&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58039&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58039&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58039&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58039&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97397) next »