Author Topic

Claudia Kosny

Thursday 09 November 2006 6:32:46 am

Comment47284

Hi Eirik

That's the problem I usually have with references - you have to be really careful with what you are doing and I am usually more of the 'just try it' type.

In the current version of the code that Derick mentions (ezmatrixdefinition::xmlString() ) they simply unset the variable so they can reuse it reuse in the loop:

        foreach ( $this->ColumnNames as $columnName )
        {
            $columnNameNode = $doc->createElementNode( 'column-name' );
            $columnNameNode->appendAttribute( $doc->createAttributeNode( 'id', $columnName['identifier'] ) );
            $columnNameNode->appendAttribute( $doc->createAttributeNode( 'idx', $columnName['index'] ) );
            $columnNameNode->appendChild( $doc->createTextNode( $columnName['name'] ) );
            $root->appendChild( $columnNameNode );
            unset( $columnNameNode );
        }

This should probably work fine in your code as well as it breaks the connection between the variable and the content so the content is still there even if you reuse the variable.

Good luck

Claudia