Okay, I am using an XML “database” with my PHP (due to having mirror sites), and my xpath() function is not playing nice with min() and max(). The relevant XML is:
[code=html]
<novel>
<chapters>
<chap num=”1″ />
<chap num=”2″ />
<chap num=”3″ />
<chap num=”4″ />
<chap num=”5″ />
<chap num=”6″ />
<chap num=”7″ />
<chap num=”8″ />
<chap num=”9″ />
</chapters>
</novel>
The PHP in question is:
[code=php]$chapnums = $novel->xpath(‘./child::chapters/child::chap/attribute::num’);
$first=min($chapnums);
$last=max($chapnums);
For some reason, I’m getting the last node with min() and the first node with max() (I’ve discovered this via rearranging the elements), but as it stands, $first ends up being “9” and $last is “1”, the opposite of what I want.
What’s going on?