PHP和Ajax(GetSimple)

i have site on cms GetSimple and want to show 10 subpage and load another with ajax.

function getSubMenu($page){ 

$children=getChildren($page); 

foreach ($children as $subpage){ 
    $title=returnPageField($subpage,'title'); 
    $url=returnPageField($subpage,'slug'); 
    echo '<a href="/'.$url.'.html"> '.$title.'</a>'; 
}

}

This code echo all subpage. How show only 10 subpage and another load after with ajax. Ajax i can do but correct php it is difficult for me. Thank if anyone will answer.

Update

function getSubMenu($page){ 

$children=getChildren($page); 
$i=0;
foreach ($children as $subpage){
    if($i==10) break; 
    $title=returnPageField($subpage,'title'); 
    $url=returnPageField($subpage,'slug'); 
    echo '<a href="/'.$url.'.html"> '.$title.'</a>';
    $i++;  
}

}

This code show only 10. How make php function which show more subpage (number from ajax). For example ajax
$.ajax({  
                    type: "POST",  
                    url: "",
                    context: this,
                    data: {
                              'num'       : '10'
                           },
                    success: function(data){
                      console.log(data);
                    },
                    error: function(data){
                      console.log('error' + data);
                    }
                });

You can break out of the foreach loop by using this.

foreach ($children as $subpage){ 
    $title=returnPageField($subpage,'title'); 
    $url=returnPageField($subpage,'slug'); 
    echo '<a href="/'.$url.'.html"> '.$title.'</a>';
    $count++;
    if($count==10) break;
}