how to get the following 10 elements in a table in PHP?


I am new to php. While I was doing a project I got stuck in a place. Consider that I have an array with 100 elements.

for ( $i=0;$i<100;$i++) {
    $related = array();
        if($g[$i] != $gs[$j])
            $related[] = $gs[$j];

What I want is to get the next 10 elements. How can I get it?

You may create function :

public function getElements($array100, $count, $from){
    $related = array();
    $j = 0;
    for ( $i = $from; $i < $from+$count; $i++) {
            $related[$j] = $array100[$i];
    return $related;

and you can call this function anywhere like :