note 49970 added to ref.simplexml

From: Date: Mon, 14 Feb 2005 05:57:00 +0000
Subject: note 49970 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-84996@lists.php.net to get a copy of this message
I'm new to PHP and XML, but I think others might pull their hair out over this too. I forgot about XML and whitespace when I was populating an array with node values, and was getting what appeared to be duplicate values despite using array_unique(). Use trim() when populating an array or assigning a variable. <?php $xml_array = array(); foreach ($resource->xpath($node_match) as $option){ $xml_array[$i] = trim($option); $i++; } $xml_unique_array = array_unique($xml_array); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49970 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49970&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49970&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49970&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49970&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49970&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49970&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84996) next »