function getExtension($file){
$exts = [];
foreach($file as $f){
$info = pathinfo($f);
//print_r($info);
$exts []= $info['extension'];
}
return $exts;
};
print_r(getExtension(["ruby.rb", "cplusplus.cpp", "python.py", "javascript.js"]));
print_r(getExtension(["code.html", "code.css"]));
<?php
function calculatescore($x) {
return [
substr_count($x, 'Y'), //substr_count-Counts how many times this data is given
substr_count($x, 'O'),
substr_count($x, 'U')
];
}
print_r (calculatescore("YOU")); // 1,1,1
print_r (calculatescore("YYOOUU)); //2,2,2
print_r (calculatescore("UUUOOYYYY)); //3,2,4