ti posto la funzione che non sbaglia sui doppi apici
codice:
function CambiaValore($nomeVar,$nuovoVal,$nomeFile){
    $nuovoVal=str_replace('"', '\"', $nuovoVal);
    $strV=explode("\n",file_get_contents($nomeFile));    
    $strO="";
    foreach ($strV as $str) {
        if(($posI=strpos($str, "['$nomeVar']"))!==false)
            $str=substr($str,0, $posI+strlen($nomeVar)+4)."=\"$nuovoVal\";\n";
        else
            $str.="\n";
        $strO.=$str;
    }
    file_put_contents($nomeFile, $strO);
}

CambiaValore("sito","Sito \"Troppo\" Figo","config.php"); //caso particolare
CambiaValore("url","http://chebellocambiare.it","config.php");