samedi 26 décembre 2015

How can I insert a if function in an array

I have an array

$data_array =

array
    (
        "limit" => $limit,
        "page_number" => $page,
        "books" => $books
    );

I want that if $books is set then the array should be

array
    (
        "limit" => $limit,
        "page_number" => $page,
        "books" => $books
    );

and if the variable $books is not set the array should be

array
(
    "limit" => $limit,
    "page_number" => $page
);

please can anybody help me.

Aucun commentaire:

Enregistrer un commentaire