<?php
//METHOD 1
$string1 = 'JOHN';
$string2 = 'SMITH';
$count_str1 = strlen($string1);
$count_str2 = strlen($string2);
if($count_str1 > $count_str2){
merge_strings($string1,$string2);
}else{
merge_strings($string2,$string1);
}
function merge_strings($string2,$string1){
$new_str = '';
$arr = str_split($string1);
for($i=0;$i<=count($arr);$i++){
if(!empty($string1[$i]))
$new_str .= $string1[$i];
if(!empty($string2[$i]))
$new_str .= $string2[$i];
}
echo $new_str;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: