我怎么能做这样的事情 - 循环通过一组无限期的数字

I'm trying to loop tru a set of numbers based on the initial number. Tried, but cant see a good way to achieve this. The thing goes inside a while loop.

<?php

$this = 1;

//If 1 then 1,4,7
//If 2 then 3
//If 3 then 10

while ( //mySql while loop ) {
    if ( $this == 1 ) {
        call example() //thrice for 1, 4, 7
    }
}

function example($a) {
    echo $a+10;
}
?>

Here, based on what $this is, I need to call function example. So if $this = 1, I need to call example thrice - $a value 1, 4, 7. If $this = 2 I need to call it once, value 3.

What would be a good way to achieve this?

Try this:

<?php 

$this = 1;

$groups = array(
    1 => array(1,4,7),
    2 => array(3),
    3 => array(10) 
);

foreach($groups[$this] as $value)
   example($value);

?>

You could use an associative array like so:

vals = array(1 => array(1, 4, 7), 2 => array(3), etc);