You have to explode
the values first
foreach (explode(', ', WEBS) as $url) { ...
explode()
will break a string into an array so that you can iterate through it
Alternatively, you could even use preg_split
.
foreach(preg_split('/,\s*/', WEBS) as $url) { ...
preg_split()
allows you to split your string based on a regular expression. It returns an array. As an example, using this regex, the space following the comma is optional.
# a string like this
foo.com, hello.com,world.com, test.com
# would still split properly to
[
'foo.com',
'hello.com',
'world.com',
'test.com'
]
Regex methods are not always necessary. But I thought I'd show you that a little more control is available when it's necessary.
Aptana is showing you an error because you can't use []
after a func()
prior to PHP 5.4. To get around that, you can do things like:
$constants = get_defined_constants(true);
$constants['user']['WEBS'];
But in this case WEBS
should be just fine. The only issue you were having is that you needed to convert the string to an array first.