3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "Ovo je samo jedan od testnih kodova"; $a = array('a','e','i','o','u'); $strlen = strlen( $str ); $siz = sizeof($a); $res = ""; $rest = ""; $t= ""; $sugl = array(); $pozsugl = array(); for( $i = 0; $i <= $strlen; $i++ ) { $char = substr( $str, $i, 1 ); $t = false; // $char contains the current character, so do your processing here for($j=0; $j<$siz;$j++) { if($a[$j] === $char) { $t = true; if($j+1 === $siz) { $res.= $a[0]; break; } else { $res .= $a[$j+1]; break; } } } if(!$t) { $res.=$char; array_push($sugl, $char); array_push($pozsugl, $i); } } echo "\n"."sugl ".printing($sugl)."\n" ; echo "\n"."pozsugl ".printing($pozsugl)."\n"; $sugl = sorty($sugl); echo "\n"."sugl poslije sorty ".printing($sugl)."\n"; echo "\n"."\n"."Rezultat prije ". $res ."\n"; echo "\n"."Rezultat nakon svega:" . changeChar($res,$pozsugl, $sugl); function sorty($c) { $siz = sizeof($c); $tmp = $c[0]; for ($i = 1; $i < $siz; $i++) $c[$i - 1] = $c[$i]; $c[$siz - 1] = $tmp; return $c; } function changeChar($str, $pozsugl, $sugl) { $strlen = strlen( $str ); $siz= sizeof($pozsugl); $rez = ""; for($i = 0; $i <= $strlen; $i++) { $char = substr( $str, $i, 1 ); for($j=0; $j<$siz;$j++) { if($i === $pozsugl[$j]) { $char=$sugl[$j]; break; } } $rez.=$char; } return $rez; } function printing($f) { $siz= sizeof($f); $t=""; for($k=0; $k <$siz; $k++) $t.=$f[$k]; echo $t; } ?>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Ov j sm jdn d tstnh kdv sugl 01346791112141617192021232425272829313335 pozsugl v j sm jdn d tstnh kdvO sugl poslije sorty Rezultat prije Ovu ji semu jiden ud tistnoh kuduve Rezultat nakon svega:v uj isme ujdine du tsitnho kduvueO

preferences:
279.25 ms | 406 KiB | 357 Q