Avatar of Colin Brazier
Colin Brazier
Flag for United Kingdom of Great Britain and Northern Ireland asked on

fundamental PHP foreach question!

Weird!  Hopefully this is an easy 1000 points for someone.

This is taken straight from the manual, and I get an error - anyone see it?  I'm using CodeIgniter if that's relevant at all.

syntax error, unexpected '$v' (T_VARIABLE) in C:\xampp\htdocs1\fobg\application\controllers\week_fixtures.php on line 31

public function date_chosen()
      {            
            $a = array(1, 2, 3, 17);

            foreach ($a as $v) {
                echo "Current value of \$a: $v.\n";
            }
      }

also flagged up in Dreamweaver:
DW screenshot
PHPCodeIgniter

Avatar of undefined
Last Comment
Colin Brazier

8/22/2022 - Mon
SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Colin Brazier

ASKER
Hi Julian, this is what I get with
public function date_chosen()
	{		
		$a = array(1, 2, 3, 17);		
	}

Open in new window

Call to undefined function  array() in C:\xampp\htdocs1\fobg\application\controllers\week_fixtures.php on line 29
Colin Brazier

ASKER
I restarted Apache and DW no longer flags an error, but despite delete cache and hard reload the error persists.

In Chrome and Edge.

I need to go out for a couple of hours. Will reboot when I get back.

Cheers
Colin Brazier

ASKER
Absolutely bizarre.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
Chris Stanyon

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Colin Brazier

ASKER
Thanks Chris, I'm new to CI so that must be the underlying reason.  I'll go back and revisit it.

Cheers
Colin Brazier

ASKER
Well I stripped it and it seems OK now.  What a waste of a morning.

Thanks both.