您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php怎么将数组中每个元素都用urlencode转一下格式

2025/6/1 8:41:17发布15次查看
php如何将数组中每个元素都用urlencode转一下格式
php中有一数组如下:
$array = array(
'test'=>'我是测试',
  'hello'=>'你好',
  'yahoo'=>'雅虎'
);
print_r($array);
运行输出为:array ( [test] => 我是测试 [hello] => 你好 [yahoo] => 雅虎 )
问题是:
如何将数组转为
$array = array(
'test'=>urlencode('我是测试'),
  'hello'=>urlencode('你好'),
  'yahoo'=>urlencode('雅虎')
);
使得输出变为:array ( [test] => %ce%d2%ca%c7%b2%e2%ca%d4 [hello] => %c4%e3%ba%c3 [yahoo] => %d1%c5%bb%a2 )
哪位知道的话帮忙解答一下,先谢谢了~~
------解决方案--------------------
php code$array = array_map('urlencode', $array);

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product