note 42258 added to function.substr

From: Date: Mon, 10 May 2004 04:03:07 +0000
Subject: note 42258 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-69396@lists.php.net to get a copy of this message
<?php $astring = "testing the word limit. There should only be words here, and nothing too long. :)"; $anumwords = 10; function strwrd($string, $numwords) { // Blow up the string $strings = explode(" ", $string); // Make string for return $string = ""; for($i = 0; $i < $numwords; $i++) { if($i > 0) { $string .= " "; } $string .= $strings[$i]; } // Return the string return $string; } // Test the new function echo strwrd($astring, $anumwords); // returns: testing the word limit. There should only be words here, ?> Still needs to have the ability to ignore <> tags. ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42258 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42258&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42258&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69396) next »