mardi 4 août 2015

Copy or Append first 13 index in Array of Strings to another and sort it - php

I am trying to work with array of string in php, its array of images and shuffle the array many times and i need to get the first 13 value from the huge array and place it in another array and then sort the second array of strings. but i am getting two errors :

Notice: Array to string conversion in /Applications/XAMPP/xamppfiles/htdocs/index.php on line 46

Warning: ksort() expects parameter 1 to be array, string given in /Applications/XAMPP/xamppfiles/htdocs//index.php on line 50
Array30.png41.png24.png31.png25.png44.png2.png15.png14.png50.png36.png38.png32.png

here is my code :

   $images = array("1.png","2.png","3.png","4.png","5.png","6.png","7.png","8.png",
        "9.png","10.png","11.png","12.png","13.png","14.png","15.png","16.png","17.png","18.png",
        "19.png","20.png","21.png","22.png","23.png","24.png","25.png","26.png","27.png","28.png",
        "29.png","30.png","31.png","32.png","33.png","34.png","35.png","36.png","37.png","38.png",
        "39.png","40.png","41.png","42.png","43.png","44.png","45.png","46.png","47.png","48.png",
        "49.png","50.png","51.png","52.png"
        );


        shuffle($images);      
        shuffle($images);      
        shuffle($images);  
        shuffle($images);  
        shuffle($images); 

        $playerArraySorted = array();

        for ($i = 0; $i < 13; $i++) {

            $playerArraySorted .= $images[$i];
        }


        ksort($playerArraySorted,2);
         echo "$playerArraySorted";



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire