Php combine an array of values into an array with double combinations string -


how can combine ad array of values array double combination string without duplications ?

for example, if have like:

array('one','two','tre','four','five'); 

i want obtain array of combinations ('one / two') 1 time , not ('two / one').

in way wanto similar to:

array('one/two', 'one/tre', 'one/four', 'one/five', 'two/tree','two/four' ....... 

suggestions ?

you can code. won't show two/one, three/two, etc (that's how understood it):

<?php $array = array('one','two','tre','four','five'); $newarray = []; foreach ($array $el) {     foreach ($array $el2) {         if ($el === $el2) continue;         $newarray[] = $el."/".$el2;     }     array_shift($array); // remove element went through } print_r($newarray); 

demo


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -