3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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; } ?>
based on krLRs
Output for 4.3.0 - 7.3.0rc4
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