Re: what is the meaning

NC wrote:
Thomas Mlynarczyk wrote:

sam wrote:

What is the meaning of this operator:-

Assignment - used in arrays?

Hm. But why the need for a special operator here? Wouldn't
a simple = have done the job just as well?

Yes, but you'd have to write it differently.

Consider this simple example:

$someArray = array('field1' => 1, 'field2' => 'two');

If it equivalent to:

$someArray = array();
$someArray['field1'] = 1;
$someArray['field2'] = 'two';

Moreover, the second option might trigger an E_NOTICE, since
you would be trying to assign a value to a not-yet-defined member
of the array...

Cheers, NC

Actually, the second option is perfectly valid. It's fine to assign to an array element which hasn't been defined yet. Just don't try to USE an array element (or any other variable) before it's been defined.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.