note 110714 added to function.substr

From: Date: Tue, 27 Nov 2012 16:23:26 +0000
Subject: note 110714 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-192159@lists.php.net to get a copy of this message
To substring a part of the text, with tag delimitation you could use a function like this function fncSubstringBalise($text, $debBalise, $finBalise) { $posDebut = strpos($text, $debBalise); $posFin = strpos($text, $finBalise); $debText = substr($text, 0, $posDebut); $finText = substr($text, $posFin + 1); $taille = strlen($text); if ($posDebut === false && $posFin === false) { $text = $text; } else { $text = $debText . $finText; } return $text; } Utilisation : fncSubstringBalise("toto fais {encore} du vélo", "{", "}") Example text : toto fais {encore} du vélo Response : toto fais du vélo ---- Server IP: 195.221.21.36 Probable Submitter: 194.119.85.99 ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- https://master.php.net/note/edit/110714 Del: integrated -- https://master.php.net/note/delete/110714/integrated Del: useless -- https://master.php.net/note/delete/110714/useless Del: bad code -- https://master.php.net/note/delete/110714/bad+code Del: spam -- https://master.php.net/note/delete/110714/spam Del: non-english -- https://master.php.net/note/delete/110714/non-english Del: in docs -- https://master.php.net/note/delete/110714/in+docs Del: other reasons-- https://master.php.net/note/delete/110714 Reject -- https://master.php.net/note/reject/110714 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192159) next »