I have tried to get the checkbox values from postmeta field but cant merge the array into single result
$get_info_contact = get_post_meta( $result, 'wpcf-society-info-contact', true );
$combined = '';
foreach($get_info_contact as $contacts){
foreach($contacts as $contact) {
$combined .= 'and';
$combined .= $contact;
}
}
echo $combined;
Output:
andalcorandpresident
Expected output:
alcor and president
I have tried to get the checkbox values from postmeta field but cant merge the array into single result
$get_info_contact = get_post_meta( $result, 'wpcf-society-info-contact', true );
$combined = '';
foreach($get_info_contact as $contacts){
foreach($contacts as $contact) {
$combined .= 'and';
$combined .= $contact;
}
}
echo $combined;
Output:
andalcorandpresident
Expected output:
alcor and president
Share
Improve this question
edited Feb 16, 2022 at 9:48
mike
asked Feb 16, 2022 at 8:26
mikemike
112 bronze badges
1 Answer
Reset to default 0$combined = '';
$k=0;
foreach($get_info_contact as $contacts){
foreach($contacts as $contact) {
//$combined .= 'and';
//if(in_array($key
if($k==0){
$combined .= ucfirst($contact);
}else{
$combined .= ' and '.ucfirst($contact);
}
}
$k++;
}
output:
alcor and president