如何转换字符串ID
$ids = '8552479333,8552438544,';
看起来像一个数组
[" 8552479333"" 8552438544"]
我试过:
$ids = (explode(",",$ids,-1));
但是这给了我:
Array ( [0] => 8552479333 [1] => 8552438544)
答案 0 :(得分:1)
这是一种非常具体的格式化方式。您可能会错过使用json编码例程来获得您正在寻找的确切结果:
<?php
$ids = '8552479333,8552438544,';
$string = json_encode(explode(',', $ids, -1));
var_dump($string);
输出显然是:
string(27) "["8552479333","8552438544"]"
答案 1 :(得分:0)
<?php
$ids = '8552479333,8552438544,';
$ids = json_encode(explode(',', $ids, -1));
print_r($ids);
?>