CopyPastor

Detecting plagiarism made easy.

Score: 0.8237073421478271; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2018-12-25
by Dipak384

Original Post

Original - Posted on 2017-08-19
by Alive to Die



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Please check this link http://php.net/manual/en/function.array-count-values.php ( array count value ) http://php.net/manual/en/function.arsort.php ( arsort )
$array = array_count_values($name_arr); //get all occurrences of each values arsort($array); print_r($array);//print occurrences array $final_array = array();
foreach($array as $key=>$val){ // iterate over occurrences array for($i=0;$i<$val;$i++){ //apply loop based on occurrences number $final_array[] = $key; // assign same name to the final array } }
print_r($final_array); // print final array
I hope this is helps you.
Thank you.
Simple way using [array_count_values](http://php.net/manual/en/function.array-count-values.php) and [arsort](http://php.net/manual/en/function.arsort.php):-
$array = array_count_values($name_arr); //get all occurrences of each values arsort($array); print_r($array);//print occurrences array $final_array = array(); foreach($array as $key=>$val){ // iterate over occurrences array for($i=0;$i<$val;$i++){ //apply loop based on occurrences number $final_array[] = $key; // assign same name to the final array } } print_r($final_array); // print final array
Output:- https://eval.in/847428

        
Present in both answers; Present only in the new answer; Present only in the old answer;