Bug - Not A Bug [mistake, never mind] xpath() returns an array with incorrect length()

philmasterplus

Active member
Example code:

Code:
string [int] nodes = xpath('<div><p>foo</p><p>bar</p><p>baz</p></div>', '//p');
print(length(nodes));

The following code prints 20, although iterating through nodes with foreach only results in 3 items.

Attempting to access an index beyond like this:

Code:
string value = nodes[10];

results in an Array index [10] out of bounds (3) error.


Edit: Never mind, I confused count(aggregate) with length(string), the latter automatically converts everything to a string.
 
Last edited:
Top