lundi 21 mars 2016

variable variables in parameter

I want to bind a variable amount of results from a database.

$randomAmount = rand(0, 10);

for ($i = 1; $i <= $randomAmount; $i++) {
    mysqli_stmt_bind_result($databaseGet, ${'op'. $i});
}

It runs the mysqli_stmt_bind_result() function a random amount of times. What I want to achieve is the $randomAmount as variable in the parameter.

So, if $randomAmount = 4, the code should do something to achieve this:

mysqli_stmt_bind_result($databaseGet, $op1, $op2, $op3, $op4;




Aucun commentaire:

Enregistrer un commentaire