All Questions

235
votes
7answers
43466 views

How can I sort arrays and data in PHP?

Due to the enormous and ever repeating amount of "How do I sort my unique snowflake of an array?" questions, this is a reference collection of basic sorting methods in PHP. Please close any questio...
72
votes
4answers
27213 views

How does RecursiveIteratorIterator work in PHP?

How does RecursiveIteratorIterator work? The PHP manual has nothing much documented or explained. What is the difference between IteratorIterator and RecursiveIteratorIterator?
144
votes
2answers
52106 views

What is Autoloading; How do you use spl_autoload, __autoload and spl_autoload_register?

I am learning advanced PHP standards and trying to implement new and useful methods. Earlier I was using __autoload just to escape including multiple files on each page, but recently I have seen a tip...
22
votes
3answers
15613 views

How to use RegexIterator in PHP

I have yet to find a good example of how to use the php RegexIterator to recursively traverse a directory. The end result would be I want to specify a directory and find all files in it with some g...
5
votes
2answers
5566 views

PHP SPL RecursiveDirectoryIterator RecursiveIteratorIterator retrieving the full tree

how can i retrieve the full directory tree using SPL ?
13
votes
11answers
19605 views

Iterate in reverse through an array with PHP - SPL solution?

Is there an SPL Reverse array iterator in PHP? And if not, what would be the best way to achieve it? I could simply do $array = array_reverse($array); foreach($array as $currentElement) {} or for...
28
votes
5answers
8008 views

Peek ahead when iterating an array in PHP

Is it possible to "peek ahead" while iterating an array in PHP 5.2? For example, I often use foreach to manipulate data from an array: foreach($array as $object) { // do something } But I often n...
43
votes
2answers
11727 views

Difference between DirectoryIterator and FileSystemIterator

PHP 5 introduced DirectoryIterator, and PHP 5.3 introduced FileSystemIterator. FileSystemIterator extends DirectoryIterator, but the documentation fails to say what extra features it brings. Can you...
21
votes
4answers
19358 views

"Indirect modification of overloaded element of SplFixedArray has no effect"

Why the following $a = new SplFixedArray(5); $a[0] = array(1, 2, 3); $a[0][0] = 12345; // here var_dump($a); produces Notice: Indirect modification of overloaded element of SplFixedArray has no ef...
5
votes
3answers
4674 views

Throwing Exceptions in an SPL autoloader?

Is there a way to throw exceptions from an SPL Autoloader in PHP in case it fails? It doesn't seem to work under PHP 5.2.11. class SPLAutoLoader{ public static function autoloadDomain($className...

Previous Next