forum by: user: nick, Post on: 2021-10-12 16:38:58, Posts: 129
php array to comma separated string with quotes
php array to comma separated string with quotes
<?php
$my_arr = array("Hi","this","is","my","array");
$result = "'" . implode ( "', '", $my_arr ) . "'";
echo $result; // 'Hi', 'this', 'is', 'my', 'array'
?>
sprintf() is a clean way of wrapping the single quotes around each item in the array
array_map() executes this for each array item and returns the updated array
implode() then turns the updated array with into a string using a comma as glue
can any one please help me on this.
(int i = 0; i < gridview1.Rows.Count; i++) { string Emp2 = ((TextBox)gridview1.Rows[i].FindControl("TxtEmp")).Text; histList.Add(Emp2.ToString()); } String EmpArrayCsv = String.Join("','", histList.ToArray());