Is it possible to make a while loop for a function but in stead of just echo it's result, store it in an array???
values in database for example: one, two, three, four.

In a normal way I do:

While (havenumbers()) {
echo havenumber(); // displays "one" etc.
}

In stead of the echo I would like to store this in an array:

$myarray = array('one','two','three','four');
Member Avatar for diafol
$r = array();
while (havenumbers()) {
    $r[] = havenumber(); // displays "one" etc.
}

I assume there's more code as we are in infinite loop territory otherwise :-)

Updated, I missed a function inside the while loop:

In a normal way I do:

While (havenumbers()) {
echo **mynumber()**; // displays "one" etc.
}

In stead of the echo I would like to store this in an array:

$myarray = array('one','two','three','four');

But how does havenumbers() flip from TRUE to FALSE ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.