php - prev() and next() return no result -


prev() , next() return no result, current(), end() , reset() can see here:

http://flamencopeko.net/songs_scans_skip_2.php
http://flamencopeko.net/songs_scans_skip_2.txt

<?php    echo current($arrfiles); ?> <br />prev:  <?php    echo prev($arrfiles); ?> <br />next:  <?php    echo next($arrfiles); ?> <br />end:  <?php    echo end($arrfiles); ?> <br />reset:  <?php    echo reset($arrfiles); ?> 

end goal make skip buttons change large scans. must done in js. i'm fine both php , js, fail see how write needed functions.


this makes array:

<?php $arrfiles = array_diff(scandir("scans", 0), array(".", "..")); $arrfiles = array_values($arrfiles); $intcountfiles = count($arrfiles); ?> 

you call prev after call current, internal pointer in array go out of rang. not come unless call reset or end.

so after have called current, pointer point index 0, called prev. pointer went out of range, , returned false.

then called next, pointer out of range, not move next, next return false.

next acts prev, once pointer goes out of range, no come back, unless call reset or end;

see zend source code blow, explains that:

    zend_api int zend_hash_move_backwards_ex(hashtable *ht, hashposition *pos)     {         hashposition *current = pos ? pos : &ht->pinternalpointer;          is_consistent(ht);          if (*current) {             *current = (*current)->plistlast;             return success;         } else             return failure;     } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -