请教数组查询替换的问题 怎么替换,js数组是用pHP输出吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //js字串$str = <<<EOD//Contents for shopping var shopping = new Array() shopping[0]=' <a href="#">{head_clothing} </a>' shopping[1]=' <a href="#">{head_bags} </a>' shopping[2]=' <a href="#">{head_shoes} </a>' shopping[3]=' <a href="#">{head_jewellery} </a>' shopping[4]=' <a href="#">{head_accessories} </a>' //Contents for mystyle var mystyle=new Array() mystyle[0]=' <a href="#">{head_going_out} </a>' mystyle[1]=' <a href="#">{head_working_girl} </a>' mystyle[2]=' <a href="#">{head_casual} </a>' mystyle[3]=' <a href="#">{head_cocktail_party} </a>' mystyle[4]=' <a href="#">{head_dinner_date} </a>' mystyle[5]=' <a href="#">{head_sportswear} </a>' //Contents for fashion var fashion = new Array() fashion[0]=' <a href="#">{head_cutting_edge_fashion} </a>' fashion[1]=' <a href="#">{head_vintage} </a>' fashion[2]=' <a href="#">{head_classic} </a>' //Contents for editor var editor = new Array() editor[0]=' <a href="#">{head_top_trends} </a>' editor[1]=' <a href="#">{head_latest_arrivals} </a>' editor[2]=' <a href="#">{head_for_him} </a>' editor[3]=' <a href="#">{head_for_her} </a>' EOD;//替换变量$arr=array ( 'head_clothing' => 'Clothing', 'head_bags' => 'Bags', 'head_shoes' => 'Shoes', 'head_jewellery' => 'Jewellery', 'head_accessories' => 'Accessories', 'head_going_out' => 'Going out', 'head_working_girl' => 'Working girl', 'head_casual' => 'Casual', 'head_cocktail_party' => 'Cocktail Party', 'head_dinner_date' => 'Dinner Date', 'head_sportswear' => 'Sportswear (polo/gilf)', 'head_cutting_edge_fashion' => 'Cutting_edge fashion', 'head_vintage' => 'Vintage', 'head_classic' => 'Classic', 'head_top_trends' => 'Top trends', 'head_latest_arrivals' => 'Latest arrivals', 'head_for_him' => 'For Him', 'head_for_her' => 'For Her', ) //替换变量foreach($arr as as $key => $value){ $str =str_replace ($key ,$value,$str );}echo $str; //替换变量foreach($arr as $key => $value){ $str =str_replace ('{'.$key.'}' ,$value,$str );}echo $str; 关于下拉菜单与数据库更新的一个问题 php连接数据库的问题 大家帮我一下,我写了$_SGLOBAL['supe_uid']=$uid;,但是在其他页面得不到其中的值 我想替换中文字符串中的某两个字符,可以不能替换 php可以编译成本地代码吗? 在php中怎样实现将表单中的内容发送到特定的邮箱? 数据库的插入给一些意见。 session的一个奇怪问题 请问在php4 中, 如何调用EXE程序啊? 请问如何将ckeditor编辑器里的内容存入mysql数据库里的TEXT字段 SESSION值混乱问题 请教关于数据库
$str = <<<EOD
//Contents for shopping
var shopping = new Array()
shopping[0]=' <a href="#">{head_clothing} </a>'
shopping[1]=' <a href="#">{head_bags} </a>'
shopping[2]=' <a href="#">{head_shoes} </a>'
shopping[3]=' <a href="#">{head_jewellery} </a>'
shopping[4]=' <a href="#">{head_accessories} </a>' //Contents for mystyle
var mystyle=new Array()
mystyle[0]=' <a href="#">{head_going_out} </a>'
mystyle[1]=' <a href="#">{head_working_girl} </a>'
mystyle[2]=' <a href="#">{head_casual} </a>'
mystyle[3]=' <a href="#">{head_cocktail_party} </a>'
mystyle[4]=' <a href="#">{head_dinner_date} </a>'
mystyle[5]=' <a href="#">{head_sportswear} </a>' //Contents for fashion
var fashion = new Array()
fashion[0]=' <a href="#">{head_cutting_edge_fashion} </a>'
fashion[1]=' <a href="#">{head_vintage} </a>'
fashion[2]=' <a href="#">{head_classic} </a>' //Contents for editor
var editor = new Array()
editor[0]=' <a href="#">{head_top_trends} </a>'
editor[1]=' <a href="#">{head_latest_arrivals} </a>'
editor[2]=' <a href="#">{head_for_him} </a>'
editor[3]=' <a href="#">{head_for_her} </a>' EOD;
//替换变量
$arr=array ( 'head_clothing' => 'Clothing',
'head_bags' => 'Bags',
'head_shoes' => 'Shoes',
'head_jewellery' => 'Jewellery',
'head_accessories' => 'Accessories', 'head_going_out' => 'Going out',
'head_working_girl' => 'Working girl',
'head_casual' => 'Casual',
'head_cocktail_party' => 'Cocktail Party',
'head_dinner_date' => 'Dinner Date',
'head_sportswear' => 'Sportswear (polo/gilf)', 'head_cutting_edge_fashion' => 'Cutting_edge fashion',
'head_vintage' => 'Vintage',
'head_classic' => 'Classic', 'head_top_trends' => 'Top trends',
'head_latest_arrivals' => 'Latest arrivals',
'head_for_him' => 'For Him',
'head_for_her' => 'For Her', )
//替换变量
foreach($arr as as $key => $value){
$str =str_replace ($key ,$value,$str );
}echo $str;
foreach($arr as $key => $value){
$str =str_replace ('{'.$key.'}' ,$value,$str );
}echo $str;