Page 1 of 1

array() with $variable bug?

Posted: 01 Apr 2026 16:20
by highend
When adding items to the array that have a comma in some of them, they are ripped apart, even when each entry is single quoted...

Is this a bug (can't say that I find this the expected behavior^^)?

Code: Select all

    $dirs = <<<'>>>'
'Hello, world!'
'You, me'
    >>>;

    $values = regexreplace($dirs, "\r?\n", ",");
    $array  = array($values);
    foreach($array as $value) {
        echo $value;
    }
This will output 4 echos...

Re: array() with $variable bug?

Posted: 06 Apr 2026 08:53
by altoclef
My experiments show that double quotes work as you expect, but single quotes are treated the same as any other character, not as enclosing a single string.

Could the reason for this be (Help: Scripting > Arrays > Special Function array()):
The values can also be in single quotes but those will not be removed.
?

Re: array() with $variable bug?

Posted: 06 Apr 2026 08:59
by highend
Ok, so it's done by design... Have to get used with that :)
Thanks!