0

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"

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by diafol
2
if($i=0)

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

if($i==0)
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;
?>
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.