functionformPhoneNumber(array$integers):string{if(count($integers)!=10){thrownewException('Please provide a valid array!');}$phone="(";foreach($integersas$index=>$number){if($number<10&&$number>=0){$phone.=$number;if($index==2){$phone.=") ";}elseif($index==5){$phone.="-";}}else{thrownewException("One of the numbers is invalid!");}}return$phone;}echoformPhoneNumber([4,5,5,4,5,1,7,8,9,0]);
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Better late than never ;p
Here's my attempt in PHP