3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php error_reporting(-1); $text = "It seems that they found us? We must urgently leave here, before it's too late. Let's run fast!"; //$text = "Ну, прости меня! Не хотела я тебе зла сделать; да в себе не вольна была. Что говорила, что делала, себя не помнила."; //$text = "Идет гражданская война. Космические корабли повстанцев, наносящие удар с тайной базы, одержали первую победу, в схватке со зловещей Галактической Империей."; $editedText =""; function makeYodaStyleText($text) { $arrayOffers = preg_split('!(\\.)|(\\!)|(\\?)!ui',$text,-1,PREG_SPLIT_NO_EMPTY); foreach ($arrayOffers as $key=>$value){ $arrayWords = preg_split("/[\s]+/",$value); $arrayWords2 = array_reverse ($arrayWords); $glue = " "; $editedText .= implode($glue,$arrayWords2); echo $editedText."1\n"; $editedText.="."; } $editedText = strtolower($text); $editedText = preg_replace('/([а-яёА-ЯЁa-z0-9«]*)(\s)([\.\,\;\:\!\?\»])/iu', '$1$3', $editedText); $editedText = preg_replace('/([\.\,\;\:\!\?\»])([а-яёА-ЯЁa-z0-9«])/iu', '$1 $2', $editedText); return $text; } $yodaText = makeYodaStyleText($text); echo "Йода говорит: {$yodaText}\n";
based on SbEnQ
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0beta1
Notice: Undefined variable: editedText in /in/8jWC9 on line 15 us found they that seems It1 us found they that seems It.late too it's before here, leave urgently must We 1 us found they that seems It.late too it's before here, leave urgently must We .fast run Let's 1 Йода говорит: It seems that they found us? We must urgently leave here, before it's too late. Let's run fast!
Output for hhvm-3.15.4
us found they that seems It1 us found they that seems It.late too it's before here, leave urgently must We 1 us found they that seems It.late too it's before here, leave urgently must We .fast run Let's 1 Йода говорит: It seems that they found us? We must urgently leave here, before it's too late. Let's run fast!