unionmat Posted January 7, 2009 Share Posted January 7, 2009 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. Link to comment https://forums.phpfreaks.com/topic/139842-php-question-involving-arrays-and-variables/ Share on other sites More sharing options...
gevans Posted January 7, 2009 Share Posted January 7, 2009 Your first code is correct as you mentioned. There is no reason why the second code should work, what are you hoping to do with; $var = explode(' ', 'hello world this is a test')[1]; Link to comment https://forums.phpfreaks.com/topic/139842-php-question-involving-arrays-and-variables/#findComment-731575 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.