将整数转换为字符串

时间:2016-12-02 09:59:44

标签: php

我有一个以逗号分隔的变量存储值

$integers = 1,5,8,4,3;

我需要像

那样创造每一个价值
$finalvalue = '1','5','8','4','3'

1 个答案:

答案 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
?>