CoderZone.org

Category: >> PHP Code >> Add a period at the end of a string if there isn't one there already Bookmark and Share

<< lastnext >>

Snippet Name: Add a period at the end of a string if there isn't one there already

Description: Simple way to add a period at the end of a string or sentence if there isn't one there already.

Also see:
» SEO string generator
» Remove empty lines from a string o...
» Find first non-numeric character i...
» Word-Unwrap Function
» Read a web page directly in to a s...
» Generate Random Keys
» Confiurable "Wrap Lines" Function
» Neatly trim a string to a set numb...
» Search array elements for a substr...
» Count capital letters in a string
» Search All Words Of A String In my...
» Remove Extra Spaces From A String
» String to Date
» Check number of characters in a ra...
» De-Pluralize a String
» Truncate Links Over X Chars long
» Nice 'Read More...' links
» Insert Into Middle Of Text
» Periodic COMMIT loop
» Strip all non-alphanumeric charact...
» Reduce multiple spaces or dashes t...
» Count words in string

Comment: (none)

Author: CoderZone
Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

// if there isn't a period at the end of $string, add one
if(substr($string, -1) != '.'){$string.= '.';}
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 7