- var_dump: documentation ( source)
- explode: documentation ( source)
<?php
$x = 'Hi Nemo';
function solution (string $str)
{
foreach(explode(' ', $str) as $wordNum => $value) {
if ($value === 'Nemo') {
return 'I found Nemo at ' . $wordNum+1;
}
}
return 'I can\'t found Nemo';
}
var_dump(solution($x));