hey,
I'm working on simplexml (sources available in pecl), and I want it to work in a foreach() loop without requiring the use of a temporary variable, ie:
books.xml
<books>
<book>
books.php
<?php
$books = simplexml_load_file('books.xml');
$booklist = $books->book; // must assign to a temporary variable foreach ($booklist as $book) {
echo "{$book->title}\n";
}
?>
So I'm trying to figure out how to use the get_property_ptr callback. I've tried a few things:
- zend_object_create_proxy. The docs say I can just return a proxy object, however, this causes a segfault for me:
return zend_object_create_proxy(object, member TSRMLS_CC);
- Adding indirection. I just call property_read, and then return a pointer to the result of the property_read call. This also yields a segfault.
So, any insights on how I might be a smarter boy, and actually get this thingy to work? :)
-Sterling
--
"Whether you think you can or think you can't -- you are right." - Henry Ford
At 22:27 18.05.2003, Sterling Hughes wrote:
Quoted text · 4 lines
hey,
I'm working on simplexml (sources available in pecl), and I want it to work in a foreach() loop without requiring the use of a temporary variable, ie:
[...]
So, any insights on how I might be a smarter boy, and actually get this thingy to work? :)
Just look into SPL
cvs co spl
and implement spl::foreach with you object the php5 version of sqlite does that and it is working fine :-)
regards
marcus