I have the following function:
function telephoneNums($telephoneNum) {
$telephoneNum = trim($telephoneNum);
$telephoneNum = preg_replace("/[^0-9]/", '', $telephoneNum);
if($telephoneNum !=8){
$errorMsg[] = 'The contact number must be exactly 8 charators long';
}
return $telephoneNum;
return array_values($errorMsg[]);
}
I am managing to return $telephoneNum but I am not managing to return $errorMsg[] - I am getting the following error PHP Fatal error: Cannot use [] for reading
I also tried return $errorMsg[];
but I still get the same errors.
How can I return $errorMsg[]