Jump to content

Why cant read it outside curly brackets


Recommended Posts

Hi, I have following problem

 

 

for($b=0;$b<$a+1;$b=$b+1)

{

$item[$b]=new item;////I even initialzed it outside for loop but still problem remains

for($i=$itemlevel[$b];$i<$itemlevel[$b+1];$i=$i+1)

{

//if($item[$b]->title!="")

$item[$b]->$title=kazmi("title",$pieces[$i]);

if($item[$b]->$title!="")echo $item[$b]->$title"<br>";//It prints here but....

                         

}

}

echo $item[$b]->$title"<br>";//It is not printing here????????

 

Can anyone please tell me how to overcome this problem

Link to comment
Share on other sites

ok the whole thing is like this:

 

 

for($b=0;$b<$a+1;$b++)

{

$item[$b]=new item;

for($i=$itemlevel[$b];$i<$itemlevel[$b+1];$i++)

{

$item[$b]->$title=kazmi("title",$pieces[$i]);

}

}

echo $title[2];///but this is not printing anything but when i tried to print it before closing last 2 brackets, it worked- why it isnt printing here

Link to comment
Share on other sites

thanks guys ,  I found the way out      following works

 

 

for($b=0;$b<$a+1;$b=$b+1)

{

$item[$b]=new item;

for($i=$itemlevel[$b];$i<$itemlevel[$b+1];$i=$i+1)

{

//if($item[$b]->title!="")

$temp=kazmi("title",$pieces[$i]);

if($temp!="")$item[$b]->$title=$temp;

//if($item[$b]->$title!="")

//echo $item[$b]->$title.$b."<br>";

}

}

echo $item[1]->$title;

 

 

i thank u all

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.