PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $testArray = ["eedadn", "drvtee", "eandsr", "raavrd", "atevrs", "tsrnev", "sdttsa", "rasrtv", "nssdts", "ntnada", "svetve", "tesnvt", "vntsnd", "vrdear", "dvrsen", "enarar"]; function getMessage($array) { $firstPosition = []; $secondPosition = []; $thirdPosition = []; $fourthPosition = []; $fifthPosition = []; $sixthPosition = []; foreach($array as $record) { $firstPosition[] = $record[0]; $secondPosition[] = $record[1]; $thirdPosition[] = $record[2]; $fourthPosition[] = $record[3]; $fifthPosition[] = $record[4]; $sixthPosition[] = $record[5]; } $firstPositionValues = array_count_values($firstPosition); $secondPositionValues = array_count_values($secondPosition); $thirdPositionValues = array_count_values($thirdPosition); $fourthPositionValues = array_count_values($fourthPosition); $fifthPositionValues = array_count_values($fifthPosition); $sixthPositionValues = array_count_values($sixthPosition); arsort($firstPositionValues); arsort($secondPositionValues); arsort($thirdPositionValues); arsort($fourthPositionValues); arsort($fifthPositionValues); arsort($sixthPositionValues); $firstPositionOrder = array_keys($firstPositionValues); $secondPositionOrder = array_keys($secondPositionValues); $thirdPositionOrder = array_keys($thirdPositionValues); $fourthPositionOrder = array_keys($fourthPositionValues); $fifthPositionOrder = array_keys($fifthPositionValues); $sixthPositionOrder = array_keys($sixthPositionValues); $result = $firstPositionOrder[0] . $secondPositionOrder[0] . $thirdPositionOrder[0] . $fourthPositionOrder[0] . $fifthPositionOrder[0] . $sixthPositionOrder[0]; echo "\n" . "The correct message is: " . $result; } getMessage($testArray);
Show:  
Copy Clear