array() with $variable bug?

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
highend
Posts: 14923
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

array() with $variable bug?

Post 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...
One of my scripts helped you out? Please donate via Paypal

altoclef
Posts: 99
Joined: 12 Oct 2012 18:54
Location: Win11 24H2 @100%

Re: array() with $variable bug?

Post 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.
?

highend
Posts: 14923
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: array() with $variable bug?

Post by highend »

Ok, so it's done by design... Have to get used with that :)
Thanks!
One of my scripts helped you out? Please donate via Paypal

Post Reply