Jump to content

problems echoing arrays


Fran
 Share

Recommended Posts

Im having problems with this little piece of code:

$slider = $pages->get("/slider/")->children();
	echo $slider(0)->images->first()->url;
	echo $slider(1)->images->first()->url;
	echo $slider(2)->images->first()->url;

gives me that error:

Error: Method name must be a string (line 1641 of /home/islak/public_html/wire/core/WireArray.php) 

Instead if i use:

$slider = $pages->get("/slider/")->children();
	
	echo $slider(1)->images->first()->url;
	echo $slider(2)->images->first()->url;

It works perfectly fine.

If I don't use the 0 index everything goes smoothly, but of course I can't show the first children's data.

Thanks for any help. :)

Link to comment
Share on other sites

Im having problems with this little piece of code:

$slider = $pages->get("/slider/")->children();
	echo $slider(0)->images->first()->url;
	echo $slider(1)->images->first()->url;
	echo $slider(2)->images->first()->url;

gives me that error:

Error: Method name must be a string (line 1641 of /home/islak/public_html/wire/core/WireArray.php) 

Instead if i use:

$slider = $pages->get("/slider/")->children();
	
	echo $slider(1)->images->first()->url;
	echo $slider(2)->images->first()->url;

It works perfectly fine.

If I don't use the 0 index everything goes smoothly, but of course I can't show the first children's data.

Thanks for any help. :)

Try:

echo $slider->eq(0)->images->frist()->url;
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...