<?php
$test1 = ['abcd','defg','ghij','jkl'];
$test2 = ['abcd','defg','hij','kle'];
$ans = '';
function test($arrs){
$oldE = lastW($arrs[0]);
foreach($arrs as $word){
$len = strlen($word);
if($len<100 && $len >2){
$newF = $word{0};
if($newF == $oldE){
$oldE = lastW($word);
$ans = 1;
}else{
$ans = 0;
}
}else{
echo "err test info";
}
}
echo $ans;
}
function lastW($a){
$b = trim($a);
$len = strlen($b)-1;
$c = $b{$len};
return $c;
}
test($test1);
test($test2);