All pastes #160334 Raw Edit

Untitled

public text v1 · immutable
·published 2006-09-04 03:19 UTC
rendered paste body
# PHP MAKES NO SENSE! :(
///// does not work
$xpath = '/';
$parts = array('one', 'two', 'three');
foreach($parts as $index => $part){
	$xpath .= $parts[$index] . '/';
	if($index+1 == strlen($parts)){
		$xpath .= 'text()';
	}
}
// $xpath should be /one/two/three/text()


///// works... why?
$xpath = '/';
$parts = array('one', 'two', 'three');
foreach($parts as $index => $part){
	$xpath .= $parts[$index] . '/';
	if($index+3 == strlen($parts)){
		$xpath .= 'text()';
	}
}
// $xpath should be /one/two/three/text()