我有一个以逗号分隔的变量存储值
$integers = 1,5,8,4,3;
我需要像
那样创造每一个价值$finalvalue = '1','5','8','4','3'
答案 0 :(得分:1)
<?php
$integers = '1,5,8,4,3'; //Convert into String
$arr = explode(',', $integers); // String to Array Conversation
foreach ($arr as $key => $value) {
$val[] = "'".$value."'"; // add your requirements here
}
$finalvalue = implode(',', $val); // Array to string
echo $finalvalue; // your final result
?>