I have rewritten and cleaned up some of your code. This is untested, but hopefully it will get you going in the right direction.
$product_ids = array(1,3,5,7,9,11,13,15,17,18,19,20,21,22,24,26,27,28,29,30,31,33,41,43,45,47,49,51,54,55,57,58);
$msg = '';
$num_items = 0;
if ( array_key_exists('num_cart_items', $response) )
$num_items = intval($response['num_cart_items']);
if ( !empty($num_items) )
{
$string1 = 'item_name';
$string2 = 'item_number';
$firstname = $response['first_name'];
$lastname = $response['last_name'];
$total = $response['mc_gross'];
for ($i = 1; $i <= $num_items; $i++)
{
$item_number = $response['item_number'.$i];
$item_name = $response['item_name'.$i];
$qty = $response['quantity'.$i];
$id = $response['item_number'.$i];
// do something with these vars since they change every iteration through the loop and only exist within the scope of the loop.
if ( in_array($item_number, $product_ids) ) {
$msg = '<p><div id="bold">Produkter tillgängliga för nerladdning/lyssning</div></p><br>';
}
}
}
echo '
<div id="wrapper">
<div id="welcomeText">Tack för ditt köp!</div>
<div class="abouttext3">Har du köpt produkter som ska laddas ned, laddar du ned dem NU till din dator. <br> Du har endast möjlighet att ladda ned från just den här sidan.<br>
Stanna kvar på sidan tills du laddat ned ALLT du köpt. <br>OBS! Om du stänger ned sidan har du inte möjlighet att komma tillbaka till den.<br>
Har du köpt en lyssning av ”Guidning till förlåtelse” lyssnar du på den HÄR och NU. <br> Var kvar på sidan tills du lyssnat klart. <br> OBS!
Om du stänger ned sidan har du inte möjlighet att komma tillbaka till den. <br />
Har du köpt varor som levereras med Posten, skickas de så snart som möjligt från oss. <br> Allra senast inom en vecka.
</div>
<div class="abouttext2">Vi önskar Dig en bra dag. <br>
Välkommen tillbaka till energyshop.se när du vill!
</div>'
. $msg; // If item_number matches any product that is for download/listetning, then print this headline