note 36249 deleted from function.substr by aidan

From: Date: Sat, 03 Jul 2004 07:45:33 +0000
Subject: note 36249 deleted from function.substr by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72368@lists.php.net to get a copy of this message
Note Submitter: sap_urg@gmx.de ---- I often had the problem to need a substring without knowing the exact length, but the sign or the position at which the string should end. JavaScript supports this feature, but php doesn't, as far as I know. Now, this function here does it: function substring($str,$start,$stop){ if(is_string($stop)) $end=strlen($str)-(strlen($str)-strpos($str,$stop)); else $end=strlen($str)-(strlen($str)-$stop); return substr($str,$start,$end); }

« previous php.notes (#72368) next »