PHP Classes

Parse error

Recommend this page to a friend!

      PHP Word Search in Array  >  All threads  >  Parse error  >  (Un) Subscribe thread alerts  
Subject:Parse error
Summary:please check this message
Messages:4
Author:Rahul
Date:2017-03-11 12:32:23
 

  1. Parse error   Reply   Report abuse  
Picture of Rahul Rahul - 2017-03-11 12:32:23
Parse error: syntax error, unexpected '[' in /Applications/XAMPP/xamppfiles/htdocs/wrd/wordsearch.php on line 76

private function search($grid, $row, $col, $word)
{
$x = [ -1, -1, -1, 0, 0, 1, 1, 1 ]; //Line 76
$y = [ -1, 0, 1, -1, 1, -1, 0, 1 ];

What is the significance of 0 , -1, 1

Thanks

  2. Re: Parse error   Reply   Report abuse  
Picture of Ravindu Taveesha Ravindu Taveesha - 2017-03-11 14:08:02 - In reply to message 1 from Rahul
please check your php version, after php 5.4 you can use the short array syntax, which replaces array() with []. if you version is lower than 5.4 replace them with array().

x,y are eight direction coordinates for an example, N(0,1), E(1,0), S(0,-1), W(-1,0)

  3. Re: Parse error   Reply   Report abuse  
Picture of Rahul Rahul - 2017-03-11 16:17:21 - In reply to message 2 from Ravindu Taveesha
Hi I have 5.6.27 running built Oct 23 2016.

After changing[ to ( I get

Parse error: syntax error, unexpected ',' in /Applications/XAMPP/xamppfiles/htdocs/wrd/wordsearch.php on line 76


  4. Re: Parse error   Reply   Report abuse  
Picture of Ravindu Taveesha Ravindu Taveesha - 2017-03-12 02:44:01 - In reply to message 3 from Rahul
This is syntax error, can i see your code ?