我想在字符串中傳遞變量,以便稍後在腳本中賦值。想要在php中傳遞字符串變量中的varialble
$message="hi $(name) your salary $(salary) is credited in your XYZ account";
foreach($arrmsgvar as $key => $value){
$temp=array_search($value[1],$upfileformat);
if($temp){
$replacement='$row['.$temp.']';
$message=str_replace($value[0],$replacement,$message);
}
}
我得到串 「喜$行[1]你的薪水$行[2]是記在您的XYZ帳戶」 中 $消息
$xdata="";
foreach($Spreadsheet as $key => $row){
$xdata.= "`$memid`|`$source`|`$mobile`|`$message`|`0`|`$msgid`||";
}
echo $xdata;
並獲得1
| 2
| 12345678
| hi $row[1] your salary $row[2] is credited in your XYZ account
| 0
| 4
||,in $ xdata
我怎樣才能在$ xdata最終輸出中獲得$ row數組的值?誰會告訴我 一種方法來做到這一點?
其實我沒有$名稱,$收入$帳戶的值在轉讓時,如果你看一下我的代碼$替換=「$行[」。$溫度。「] 「; ..我嘗試傳遞只是變量到字符串和後來的值分配給foreach中的變量($ Spreadsheet爲$ key => $ row){}在這個循環 – Ekky 2013-04-24 12:43:58