note 70545 added to function.preg-replace

From: Date: Fri, 20 Oct 2006 07:22:52 +0000
Subject: note 70545 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-118815@lists.php.net to get a copy of this message
Quick note, took me some time to figure out. I needed to create ebay feed (from online store) and ebay product names should not be longer than 55. Many online store products had a long name. This will cut whole sentence up to 55 characters and cut whole word if half of it vent over 55th character. $text01 = "Please note that periodically, the developers may go through the notes..."; $text1 = preg_replace("~^(.{1,55})\b.*~", "\\1", $text01); echo $text1; ---- Server IP: 64.71.164.2 Probable Submitter: 67.167.85.235 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/70545 Del: integrated -- https://master.php.net/note/delete/70545/integrated Del: useless -- https://master.php.net/note/delete/70545/useless Del: bad code -- https://master.php.net/note/delete/70545/bad+code Del: spam -- https://master.php.net/note/delete/70545/spam Del: non-english -- https://master.php.net/note/delete/70545/non-english Del: in docs -- https://master.php.net/note/delete/70545/in+docs Del: other reasons-- https://master.php.net/note/delete/70545 Reject -- https://master.php.net/note/reject/70545 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#118815) next »