Jump to content

PHP Question involving arrays and variables


unionmat

Recommended Posts

Hi Guys,

 

I am new here, and have a problem for you that I have not been able to solve.

 

The code below works:

<?php

$var = explode(' ', 'hello world this is a test');

echo $var[1];

?>

 

but this code below does not work, why? and how can I make it work?

<?php

$var = explode(' ', 'hello world this is a test')[1];

?>

 

I have tried many things and cannot figure it out.  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.