Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我收到这种格式的数据,例如:
C00001,C00302,C00303,C00287,C00286,C00285,C00017
在一个变量中,但我需要这种形状:
'C00001','C00302','C00303','C00287','C00286','C00285','C00017'
我是 mysql 新手,请帮忙
您可以explode对数据进行修改,然后重新修改implode。
explode
implode
$data = 'C00001,C00302,C00303,C00287,C00286,C00285,C00017'; $arr = explode(',', $data); $new_arr = array_map(function($a){ return "'{$a}'"; }, $arr); $new_data = implode(',', $new_arr);