I have an indexed array but I need to convert it in simple array just like below. hope you can help me.
This is my current array
Array
(
[0] => 4
[1] => 4
[2] => 0
[3] => 3
[4] => 3
)
But I need to convert it into like this.
array("4","4","0","3","4");
or much better if unique like this
array("4","4","0","3","4");
Thank you
I'm not sure to understand your request, I propose you to test this:
$array = [
"0" => "4",
"1" => "4",
"2" => "0"
];
$string = "";
foreach ($array as $key => $value) {
$string = $string.$value;
}
It returns "440".
Hope it can help you
try this one:
$a = array("4", "4", "0", "3", "4");
$str = 'array(';
foreach ($a as $key => $value) {
$str.='"' . $value . '",';
}
$str = trim($str, ',');
$str.=')';
echo $str;
Outpur: array("4","4","0","3","4")