aa-test - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of aa-test.php
- <?php
- function testTask($word1, $word2){
- $cnt = 0;
- foreach($word2 as $key=>$char){
- if(!isset($word1[$cnt])) return false;
- //echo $char.' == '.$word1[$cnt].'('.$cnt.')'.PHP_EOL;
- if($char !== $word1[$cnt]){
- if(is_numeric($char)){
- $cnt += $char;
- } else {
- return false;
- }
- } else {
- $cnt++;
- }
- }
- return true;
- }
- $testWords = [['anton', 'an3n'],['anton', 'an2n']];
- foreach($testWords as $case){
- $word1 = str_split($case[0]);
- $word2 = str_split($case[1]);
- var_dump(testTask($word1,$word2));
- }