3v4l.org

run code in 500+ PHP versions simultaneously
<?php //If you add to the end the varname as Mobin F.R.G suggest in the comments $text1 = array ('fr', 'hr', 'test1'); $text2 = array ('el', 'hr', 'test2'); $text3 = array ('bg', 'en', 'es', 'test3'); $text4 = array ('bg', 'el', 'en', 'es', 'test4'); $text5 = array ('bg', 'el', 'en', 'es', 'fr', 'hr', 'test5'); //I assume you didn't mean to make and array of array. $order1 = array('bg', 'el'); $finalstr = ''; $aux = 0; //Checks first element $containPrev1 = in_array($order1[0], $text1); $containPrev2 = in_array($order1[0], $text2); $containPrev3 = in_array($order1[0], $text3); $containPrev4 = in_array($order1[0], $text4); $containPrev5 = in_array($order1[0], $text5); while($aux< count($order1)){ if (in_array($order1[$aux], $text1) && $containPrev1 == true) { $lastpos = (count($text1)-1); if(strpos($finalstr, $text1[$lastpos]) == false){ $finalstr = $finalstr . $text1[$lastpos].' '; } } else{$containPrev1 = false;} if (in_array($order1[$aux], $text2) && $containPrev2 == true) { $lastpos = (count($text2)-1); if(strpos($finalstr, $text2[$lastpos]) == false){ $finalstr = $finalstr . $text2[$lastpos] . ' '; } } else{$containPrev2 = false;} if (in_array($order1[$aux], $text3) && $containPrev3 == true) { $lastpos = (count($text3)-1); if(strpos($finalstr, $text3[$lastpos]) == false){ $finalstr = $finalstr . $text3[$lastpos] . ' '; } } else{$containPrev3 = false;} if (in_array($order1[$aux], $text4) && $containPrev4 == true) { $lastpos = (count($text4)-1); if(strpos($finalstr, $text4[$lastpos]) == false){ $finalstr = $finalstr . $text4[$lastpos] . ' '; } } else{$containPrev4 = false;} if (in_array($order1[$aux], $text5) && $containPrev5 == true) { $lastpos = (count($text5)-1); if(strpos($finalstr, $text5[$lastpos]) == false){ $finalstr = $finalstr . $text5[$lastpos] . ' '; } } else{$containPrev5 = false;} $aux++; } //Just to print the string $finalstr = trim($finalstr); $arrayfinal = explode(" ", $finalstr); print_r($arrayfinal);
Output for git.master_jit, git.master, rfc.property-hooks
Array ( [0] => test3 [1] => test4 [2] => test5 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.06 ms | 1939 KiB | 4 Q