I have a variable defined like so: $var = \"1, 2, 3\"; & I have an array: $thePostIdArray = array(1, 2, 3);
The Array above wo
For developer who wants result with and in the end can use the following code:
$titleString = array('apple', 'banana', 'pear', 'grape');
$totalTitles = count($titleString);
if($totalTitles>1)
{
$titleString = implode(', ' , array_slice($titleString,0,$totalTitles-1)) . ' and ' . end($titleString);
}
else
{
$titleString = implode(', ' , $titleString);
}
echo $titleString; // apple, banana, pear and grape