如何在数组中搜索时计算值

I need some help with my PHP script. I want to add the value in each time when it add up to each value using id=row1-VALUE

Example:

row1-1
row1-2
row1-3
..etc

Using this code:

$program_title = $html->find('li[id=row1-1]', 0)->plaintext;

Here is the full code:

$base = $row['links'];

$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_URL, $base);
curl_setopt($curl, CURLOPT_REFERER, $base);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$str = curl_exec($curl);
curl_close($curl);


// Create a DOM object
$html = new simple_html_dom();
// Load HTML from a string
$html->load($str);

$channel_name = $_GET['channels'];
$show_id = 1;


$program_title = $html->find('li[id=row1-1]', 0)->plaintext;
?>

Can you please show me an example of how i can add the value next to the row1- to count up the value in each time and if the row1-20 or whatever it is that do not exist then I want to skip it to row2-1?

Use nested for loop to accomplish this:

for ($i = 1; $i <= 5; $i++) {
    for ($j = 1; $j <= 5; $j++) {
        $program_title = $html->find("li[id=row$i-$j]", 0)->plaintext;
        if (!empty($program_title)) {
            // The value exists
        } else
            break;
    }
}

Note: Replace number 5 with the limit you have for rows.