Results 1 to 10 of 10

Thread: preg_replace

Threaded View

  1. #1

    Thread Starter
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616

    preg_replace

    PHP Code:
    // Parse all blogCode used in this comment/blog
    // $contents = preg_replace("/\\[b\\](.?*)\\[\\/b]\\]/is","<b>$1</b>",$contents);
    function ParseCode($text "Invalid use of Function",$abCode 1) {
        if (
    $abCode) {
            
    $query mysql_query("select * from abCode");
            for (
    $i 0$i mysql_numrows($query); $i++) {
                
    $abOpenTag mysql_result($query,$i,"abOpenTag");
                
    $abCloseTag mysql_result($query,$i,"abCloseTag");
                
    $htmlOpenTag mysql_result($query,$i,"htmlOpenTag");
                
    $htmlCloseTag mysql_result($query,$i,"htmlCloseTag");
                
    $text preg_replace("/".addslashes($abOpenTag)."(.?*)".addslahses($abCloseTag)."/is","$htmlOpenTag$1$htmlCloseTag",$text);
            }
            return 
    $text;
        }

    This is my first experiment with preg_replace and I want to know if this will give me the desired effect if...
    &nbsp;&nbsp;$abOpenTag has the value of "[ b ]" (without the spaces inbetween)
    &nbsp;&nbsp;$abCloseTag has the value of "[ /b ]" (without the spaces inbetween)
    &nbsp;&nbsp;$htmlOpenTag has the value of "<b>"
    &nbsp;&nbsp;$htmlCloseTag has the value of "</b>"

    Will that work, or do I need to change a few things? I tried installing IIS yesterday but had all kinds on my laptop (i think its too slow ) but if anyone could help me here, I would appreciate it.
    Last edited by cpradio; Jun 7th, 2002 at 08:43 AM.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

Posting Permissions

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



Click Here to Expand Forum to Full Width