It looks like you want the last column values as a string.
Method 1:
Collect all last values of each subarray in a new variable, say $result
and implode()
them later.
<?php
$array = [
["STRG008c0",2,0,"orange","***STRG008*#*"],
["STRG009c0",3,0,"orange","***STRG009*#*"],
["STRG001c0",2,0,"green","***STRG001*#*"],
["STRG003c0",3,0,"green","***STRG003*#*"],
["STRG002c0",4,0,"green","***STRG002*#*"]
];
$result = [];
foreach ($array as $subarray) {
$result[] = end($subarray);
}
$result = implode(",",$result);
echo $result;
Method 2:
You can use array_column()
to filter only last column values and implode()
them later. This would be a one-liner.
<?php
$array = [
["STRG008c0",2,0,"orange","***STRG008*#*"],
["STRG009c0",3,0,"orange","***STRG009*#*"],
["STRG001c0",2,0,"green","***STRG001*#*"],
["STRG003c0",3,0,"green","***STRG003*#*"],
["STRG002c0",4,0,"green","***STRG002*#*"]
];
$result = implode(",", array_column($array,4));
echo $result;