Re: Strange hidden string to array conversion



ScriptKid wrote:
Hugh Oxford pisze:
So what are you trying to achieve with $s[4] = 'A'?

AFAIK, doing that will create an array, and set the fifth element to 'A'.

No, I'm trying to achieve

$s == ' A';

by writing:

$s = '';
$s [4] = 'A';

which should be possible according to documentation, but as Curtis wrote
(thanks, Curtis!) array conversion is chosen over string padding.

Sad, but true.

I don't see where the documentation says you can do that. The doc specifies "Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in $str[42]. ".

So you can access characters in the string, but it says nothing about being able to access characters which don't exist.

If you want it equal to ' A', then set it to ' A'.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.