mardi 26 avril 2016

How to organize large array used by function

I have a large array of URLs, up to 500 URLs. I have a function in my helper class, Helpers.php, that I loop through this array and perform actions on each URL within the array.

Currently, I have the array within the function, but this seems really messy to me, like:

function getURLData() {
    $urls = array( ... 500 URL array ... )
    foreach ($urls as $url) {
        // perform actions on $url
    }
}

However, the function looks incredibly cluttered with all 500 URLs being listed there. How can I reorganize this to make the function more readable? Should I store the array in a separate file? How? Where?

P.S. I am using Laravel 5.2.

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire