Custom Markup Code - Part 1

Category: PHP
Reviewed by: Chiggins   
Reviewed on: Nov 01 2008
» Discuss this topic ( Posts)

 
function convert_markup( $sString ) {
    $string = $sString;
    
    // Markup conversion done here
 
    // Create line breaks
    $string = nl2br( $string );
 
    // Output formatted text
    return $string;
}

Now there is our basic template. The function "convert_markup" will do what it says, convert the text to markup. It takes one argument, $sString. That would be the text to be converted. No markup codes are in the function yet, because we will go over those on the next page. After all the markup is converted, it takes any new lines, turns them into line breaks, and returns the formatted string.