SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Threaded View

  1. #1
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    str_replace in a function

    Anybody have any clue how to get this to work? If I do a manual str_replace, it works but when I try to do it as a function, it does not. I want to do it as a function b/c I want to add link support to the function as well. Anyways, here's the code (and the query using strings DOES work ):
    PHP Code:
    $code=array("\n",
        
    "/r",
        
    "/n/r",
        
    '[ i]',
        
    '[ /i]',
        
    '[ b]',
        
    '[ /b]',
        
    '[ u]',
        
    '[ /u]',
        
    '[ list]',
        
    '[ *]',
        
    '[ /*]',
        
    '[ /list]');
    $html=array("<br />",
        
    "<br />",
        
    "</p>\n</p>",
        
    '<span style="font-style : italic ;">',
        
    '</span>',
        
    '<span style="font-weight : bold ;">',
        
    '</span>',
        
    '<span style="text-decoration : underline ;">',
        
    '</span>',
        
    '<ul>',
        
    '<li>',
        
    '</li>',
        
    '</ul>');
    function 
    tohtml($message)
    {
        
    $output=str_replace($code,$html,$message);
        return 
    $output;
    }
    function 
    fromhtml($message)
    {
        
    $output=str_replace($html,$code,$message);
        return 
    $output;
    }

    $query "SELECT * FROM $table WHERE $field = '$page'";
    $qyres mysql_query($query);
    while(
    $row=mysql_fetch_array($qyres)) {
        if(!isset(
    $sid)) {
            
    $pid=$row['pageID'];
            
    $pname=$row['pagename'];
            
    $sppage=$row['specialpage'];
            
    $content=tohtml($row['content']);
            }

    yada.... 
    Last edited by Sketch; Feb 22, 2002 at 00:22.
    Aaron Brazell
    Technosailor




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •