I have array values if there are two values i need to add a string "AND" if single value "AND" string should not be added. i have tried with the following code. cant get the required output
$unserialize_meta = array(0=>"Alcor",1=>"President",2=>"Treasurer");
$checks = array();
foreach($unserialize_meta as $meta){
$checks[]= $meta;
}
echo implode(" And ",$checks);
Output:
Alcor And President
Alcor And President And
required output:
Alcor And President
Alcor And President
$checks = array_values($unserialize_meta);Treasurerin your expected output?implode(). You shouldn't be getting an extraANDunless there's an empty value in the array.,echo. There must be more that you're not showing us.Alcor And President Andmeans there are 3 values and last one is empty string/null