Adhy KunKun Adhy KunKun - 16 days ago 5x
PHP Question

Looping function if the function result is empty

I am confused to solve my code...
Somebody, can you please help me...

Here is my code, so far...

$r = get_pht_desc($wordString);

if (empty($r)) {

while (count($r) < 1 ) {
$r1 = get_pht_desc($wordString);
print_r ($r1);

} else {
print_r ($r);

What I want is :

If the result of my Function $r = get_pht_desc($wordString) is empty, it will repeat the function until the result is not empty or greater than zero.

Note: result of $r is an array, so I used count to check if the result is empty or not

I tried a lot of way, I think it's the way but still didn't work.
The while function gave me result

Array ( ) Array ( ) Array ( ) Array ( )....

Until Unlimited...

Thanks before.


USe Below Code

$r = array();
while (empty($r)) {
    $r = get_pht_desc($wordString);
print_r ($r);   

but i think it will be endless loop is get_pht_desc($wordString) return empty result bcoz might every time it return same results.