Jump to content

[SOLVED] passing an array into a function


purencool

Recommended Posts

I have been look at this code for 50mins and  i can't work out why it won't work :facewall:

 

what I am trying to do is this.

function a(){
arrayA
check = function b(arrayA);
}
function b(arrayA){
do something
return array
}

 

All I get is errors! Saying that array_push is looking for an array!

function CreateMenu($directory) {
// above  sorts out array
    print_r($folderContents);                                 // I get a full array at this point
    $folderContents1= MenuSort($folderContents);  // this comes back empty
    print_r($folderContents1);                               // this shows nothing in the array
    array_push($folderContents1,"</ul>");             //because above is now empty error start
    $menufolderContents .= implode(" ",$folderContents1);

    return $menufolderContents;
}

function MenuSort($folderContents){
    //Alphabetical  order (sort array)
   // sort($menuCreation);

    //About Us
        //search
        //$key = array_search('Home', $menuCreation);
        //echo $key;

    echo "this is menu creation". $menuCreation;
    print_r($menuCreation);
    return $menuCreation;
}



Link to comment
https://forums.phpfreaks.com/topic/170212-solved-passing-an-array-into-a-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.