Questions tagged [recursiveiterator]

24 questions
3
votes
1 answer

How do I iterate through a dictionary of lists and pair each iteration with an item from all the keys?

I need to iterate through a dictionary of lists, not knowing how many lists the dictionary will have, but still pair off each list value with any other list value produced from another key in the dictionary (if another one exists). I have the…
Joe Davis
  • 33
  • 3
3
votes
2 answers

PHP RecursiveDirectoryIterator return but do not traverse directory matching "x"

I am writing a disk catalogue application in PHP. My script loops over directories, storing all filenames and metadata in a database. There are certain directories I do not want to travel down. I want the iterator to simply return the names of those…
utt50
  • 155
  • 2
  • 9
2
votes
1 answer

PHP RecursiveIteratorIterator not outputting all keys

I have the following multidimensional array: $array = array( 1 => null, 2 => array( 3 => null, 4 => array( 5 => null, ), 6 => array( 7 => null, ), ) ); If I use the following code to iterate over the…
nick
  • 3,544
  • 1
  • 26
  • 22
2
votes
1 answer

iterating through S3 bucket with stream wrapper

I am trying to list all the items in my Amazon S3 bucket. I have several nested directories in it. dir1/ dir1/subdir1/ dir1/subdir2/ dir1/subdir3/ dir2/ dir2/subdir1/ dir2/subdir2/ ... Each subdirectory contains several files. I need to get a…
1
vote
2 answers

php evaluating multidimensional array from inner array to outer araray

How do I solve the following problem using PHP RecursiveIteratorIterator? $arr = array( "sum"=>array(2,4,6, "multiply" => array(1,3,5) ), "multiply"=>array(3,3,3, "sum" => array(2,4,6) ), ); I am expecting the following answers (2 + 4 + 6…
subra
  • 35
  • 6
1
vote
2 answers

How to iterate through a directory and sub-directories using a URL

I'm trying to iterate through files in a directory and files in sub-directories within:
Program-Me-Rev
  • 6,184
  • 18
  • 58
  • 142
1
vote
1 answer

How to Exclude Certain Folders from being added to zip generated by php

I want to exclude certain files like index.php from being added to the zip which is generated by the code below. I tried some ways but none worked. Please see through it and help me. $dir = './archive/'; $zip_file = 'All-file.zip'; // Get real…
1
vote
1 answer

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(public/user_/,public/user_/)

I am getting this error while using the RecursiveDirectoryIterator. Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(public/user_/,public/user_/): The system cannot find the path…
1
vote
2 answers

Recursively deleting a directory fails after zipping and downloading its contents

I followed this SO thread to recursively delete a directory (see code below). The problem is I can't get these commands to do their things after I have zipped the directory's contents and downloaded the zip file. File/folder permissions don't…
tim peterson
  • 23,653
  • 59
  • 177
  • 299
1
vote
1 answer

What exactly does PHP SPL RecursiveIterator::getChildren() return?

I am learning about Marcus Boerger's Standard PHP Library (SPL). I have implemented my own RecursiveIterator which, by inheritence, implements the Iterator interface. It also implements Countable. I am confused by the current(), getChildren() and…
JW.
  • 4,821
  • 5
  • 43
  • 60
0
votes
1 answer

Recursively traverse and compare a multi-dimensional array with a one dimensional array and build a diff using the mapped values

Given these two arrays (one comes from json, decoded into a PHP array while the other is from a DB so it's 1 dimensional) I need to somehow compare only some of the values to build a new nested array with only the changed values. $data_array = [ …
0
votes
1 answer

PHP Cleaning up nested arrays with unknown structure

Let's assume I have an array like so: [1=>[1=>2,2=>"something"],2=>[1,2],3=>"hello"] The array has a "unorganized" structure with subarrays other values. I want to run a htmlentities function on each value to make sure nothing bad is inside the…
Maciek Semik
  • 1,872
  • 23
  • 43
0
votes
2 answers

Rename all subdirectories within a directory recursively

I'm currently using the following code to list all of the subdirectories within a specific directory. $dir = realpath('custom_design_copy/'); $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir),…
user3308219
  • 157
  • 2
  • 11
0
votes
0 answers

Using recursive function to delete files and directories, but how does it work?

I have some code I'm using I found on here, but would like to know how it actually works and what it's doing. I gather it iterates through the various files and folders and removes them, but would like to know the mechanics so that I can make…
0
votes
1 answer

json_encode returning null from php array

I have an array in php from a recursiveiteratoriterator, It loads fine when I dump the file. When I try to json_encode it and pass it to the browser I get 2 scenarios: I echo the json_ encode and get the…
John Stapleton
  • 160
  • 2
  • 14
1
2