i try to replace array values by another one in a string, i can't find any PHP function could do this.
this is my code :
array_replace(array('id','quote_id'), array('new field 1','new field 2'), $string)
this is my string
SELECT id,quote_id,total FROM quotes
$ar = array('id','quote_id');
$replace = array('new field 1','new field 2');
$str = 'SELECT id, quote_id,total FROM quotes';
for($i=0;$i<count($ar);$i++) {
$str = preg_replace("/\b$ar[$i]\b/u", $replace[$i], $str);
}
echo $str;
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加