the code below is not working

<?php
$product=array();
$plicense_key=array();
$count=2;
$product['0']="The life of game";
$product['1']="The game of life";
$product['2']="Congo";
$plicense_key['0']="xf456-sdfrd";
$plicense_key['1']="xf456-sdfrd";
$plicense_key['2']="xf456-sdfrd";
$to=$user['email'];
$subject="Thank you for purchasing";
$txt= "Thank for purchasing our product.your product related information is-";
for($i=0; $i<$count; $i++)
{
	if($i=0)
	{
		$txt.="product:Licence_key";
	}
	$txt.=$product[$i]." :".$plicense_key[$i];
}
echo $txt;
?>

It is giving error "
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 33292273 bytes) in C:\xampp\htdocs\digital-downloads-pro\test1.php on line 20"

Member Avatar for diafol
if($i=0)

This sets $i to 0 every time, so your loop will run forever. Change this to:

if($i==0)
if($i=0)

This sets $i to 0 every time, so your loop will run forever. Change this to:

if($i==0)

thank you for answer .your answer is working.i have one more proplem to make new line with \n in the text . it is not working in this text

<?php
ini_set("memory_limit","80M");
$product=array();
$plicense_key=array();
$count=2;
$product['0']="The life of game";
$product['1']="The game of life";
$product['2']="Congo";
$plicense_key['0']="xf456-sdfrd";
$plicense_key['1']="xf456-sdfrd";
$plicense_key['2']="xf456-sdfrd";
$to=$user['email'];
$subject="Thank you for purchasing";
$txt= "Thank for purchasing our product.your product related information is-";
for($i=0; $i<=2; $i++)
{
	if($i==0)
	{
		$txt.="product:Licence_key"."\n";
	}
	$txt.=$product[$i]." :".$plicense_key[$i]."\n";
}
echo $txt;
?>

You are outputting HTML, so a \n has no visual effect, try <br/>

Member Avatar for diafol

Agree with Prit. However, you could use echo nl2br(...) to change \n to <br />, but I don't know whether that would be an advantage or not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.