I think I need some explanations about the recursivity... I looked at some same issues over forums but it didn't help me a lot.
Here is my function :
public function tas ($nb_gift, array $winners)
{
if ( !empty( $nb_gift ) ){
$id_winner = rand( 10, 15 );
if ( !$this->_in_array_r($id_winner, $winners) ){
$existing_user = $this->getWinner( $id_winner );
}
if( !empty( $existing_user ) && $nb_gift > 0 ){
$winners[] = array( $existing_user, 'iphone5');
$this->tas($nb_gift - 1, $winners);
}
else {
if($nb_gift > 0)
{
$this->tas($nb_gift, $winners);
}
}
}
else {
//print_r($winners);
return $winners;
}
}
At the end I have an array composed of the winners. Even if the print_r works, the return doesn't give me back my array. Does the function need some optimisation ?