Can i use this code like this?

Discussion in 'PHP' started by baris22, Dec 29, 2008.

  1. #1
    Hello,

    This is the original code.

    
    
    $find[] = '“'; // left side double smart quote
    $find[] = '”'; // right side double smart quote
    $find[] = '‘'; // left side single smart quote
    $find[] = '’'; // right side single smart quote
    $find[] = '…'; // elipsis
    $find[] = '—'; // em dash
    $find[] = '–'; // en dash
    
    $replace[] = "";
    $replace[] = "";
    $replace[] = "";
    $replace[] = "";
    $replace[] = "";
    $replace[] = "";
    $replace[] = "";
    
    $text = str_replace($find, $replace, $text);
    
    
    PHP:
    Can i use it like this. Can i use

    
    $replace[] = "";
    
    PHP:
    once instead of the number of $find

    
    
    $find[] = '“'; // left side double smart quote
    $find[] = '”'; // right side double smart quote
    $find[] = '‘'; // left side single smart quote
    $find[] = '’'; // right side single smart quote
    $find[] = '…'; // elipsis
    $find[] = '—'; // em dash
    $find[] = '–'; // en dash
    
    
    $replace[] = "";
    
    
    $text = str_replace($find, $replace, $text);
    
    
    PHP:

     
    baris22, Dec 29, 2008 IP
  2. multicolorguru

    multicolorguru Peon

    Messages:
    81
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sure wilil work just fine you can feed str_replace an array as the needle and a simple string as the replacement.
     
    multicolorguru, Dec 29, 2008 IP