note 107876 added to function.ucfirst

From: Date: Mon, 12 Mar 2012 19:48:26 +0000
Subject: note 107876 added to function.ucfirst
Groups: php.notes 
Request: Send a blank email to php-notes+get-186613@lists.php.net to get a copy of this message
<?php // Custom function returns a string with the first word in a bigger fontsize, with a default of 22px. function ucsentance($string, $fontSize=22) { // Do some basic processing on the data and find the first space before returning the modified string. $trimmed = trim($string); $getSpace = strpos($trimmed,' '); $firstWord = substr($trimmed, 0, $getSpace); $firstWord = ucfirst($firstWord); $afterFirstWord = substr($trimmed, $getSpace); $output = "<b style='font-size: " . $fontSize . "px;'>" . $firstWord . "</b>" . $afterFirstWord; return $output; } // Example of it's use $string = "Hello World, I am a bouncy castle!"; echo ucsentance($string); ?> This will yield <b style="font-size: 22px;">Hello</b> World, I am a bouncy castle! ---- Server IP: 69.147.83.197 Probable Submitter: 41.132.71.46 ---- Manual Page -- http://www.php.net/manual/en/function.ucfirst.php Edit -- https://master.php.net/note/edit/107876 Del: integrated -- https://master.php.net/note/delete/107876/integrated Del: useless -- https://master.php.net/note/delete/107876/useless Del: bad code -- https://master.php.net/note/delete/107876/bad+code Del: spam -- https://master.php.net/note/delete/107876/spam Del: non-english -- https://master.php.net/note/delete/107876/non-english Del: in docs -- https://master.php.net/note/delete/107876/in+docs Del: other reasons-- https://master.php.net/note/delete/107876 Reject -- https://master.php.net/note/reject/107876 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186613) next »