Page 1 of 1

SC global array

Posted: 10 Mar 2023 15:43
by pirgygab
Hi,
I have some problem with array declared as global.
first example, without global declaration:

Code: Select all

	$name = array("cat"=>"pussy","dog"=>"rex");
	$name["cat"] = "tom" ;
	$a = "dog" ;
	$name[$a] = "snoopy" ;
	$Txt = "" ;
	$i = 0 ;
	foreach($name as $sKey => $sValue) {
		$i++;
		$Txt .= "- $i : $sKey = $sValue" . <crlf> ;
	}
	echo $Txt ;
works as expected:
- 1 : cat = tom
- 2 : dog = snoopy

Then, just adding global declaration

Code: Select all

	global $name[] ;
	$name = array("cat"=>"pussy","dog"=>"rex");
	$name["cat"] = "tom" ;
	$a = "dog" ;
	$name[$a] = "snoopy" ;
	$Txt = "" ;
	$i = 0 ;
	foreach($name as $sKey => $sValue) {
		$i++;
		$Txt .= "- $i : $sKey = $sValue" . <crlf> ;
	}
	echo $Txt ;
a 3rd key is added...
- 1 : cat = tom
- 2 : dog = rex
- 3 : $a = snoopy

Is there any limitation with global array that I missed?

(Windows 11 22H2, XYplorer 24.20)

Re: SC global array

Posted: 10 Mar 2023 17:30
by admin
Indeed! Fix comes. :tup:

Re: SC global array

Posted: 11 Mar 2023 10:30
by pirgygab
OK with v24.20.0020

Thanks!