473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

array data matches but array created in loop doesn't work

I have the exact same data in two arrays, but only the array created
like so will work:

$spaw_imglibs = array(
array(
'value' => '/youth/pics/Member pics/',
'text' => 'Member pics',
),
array(
'value' => '/youth/pics/Group pictures/',
'text' => 'Group pics',
),
);

This array creates an exact copy of the array above:

$spaw_imglibs = array();
$test= array();
$base = './pics/';
if(is_dir($base)){
$dh = opendir($base);
while (false !== ($dir = readdir($dh))) {
if (is_dir($base . $dir) && $dir !== '.' && $dir !== '..') {
$subs = $dir ;
$subbase = $base . $dir . '/';
$test[value]="/youth/pics/$dir/";
$test[text]="Subject: $dir";
array_push($spaw_imglibs,$test);
}
}
closedir($dh);
}
The code above just browses the directory tree of the server and fills
in the same data as the first array, by finding the directory name and
filling in $dir in the path. I would like to use this looped array
because the directory tree will be expanding and I don't want to have
to manually add to the array every time a new directory is created.
I tested the arrays like so:
$spaw_imglibs = array(
array(
'value' => '/youth/pics/Member pics/',
'text' => 'Member pics',
),
array(
'value' => '/youth/pics/Group pictures/',
'text' => 'Group pics',
),
);

They both display the same output, but the second array doesn't work
for SPAW Editor version 1.0.3. The $spaw_imglibs array is used to
store directories of images for this WYSIWYG editor. I can't tell why
the 2nd array won't work, unless the syntax of
$test[value]="/youth/pics/$dir/" somehow creates a different array
from the syntax 'value'=>'/youth/pics/Member pics/'. The $dir
variable holds exactly "Member pics", so it seems they would be the
same. When I use the second array in SPAW, the image browser window
comes up with no directories shown. The first array shows the two
directories properly in the image browser.
Could array_push be changing some structure of the array? Could PHP
be converting the spaces into something weird that messes up SPAW?
Any help will be greatly appreciated.
Jul 16 '05 #1
1 2780
anyone have an idea?
Jul 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
5
by: Richard Berg | last post by:
Hello, I need to search a byte array for a sequence of bytes. The sequence may include wildcards. For example if the array contains 0xAA, 0xBB, 0xAA, OxDD then I want to be able to search for...
4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
11
by: Walter Dnes (delete the 'z' to get my real address | last post by:
I've noticed a few threads (full of sound and fury, signifying nothing) here recently about allocation of large memory blocks. I'm about to start on a personal pet project where I'll be using...
32
by: Joe Rattz | last post by:
Hmmm, I wrote the following code. I want an array of bools and I want to intialize them to false. bool bits = new bool; foreach(bool bit in bits) { bit = false; } The compiler complains...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
4
by: foker | last post by:
I have an array with 50 elements in it, and a huge document with like 35,000 words on it. What I want to do is count the number of times each element has appeared in the document. This is what I...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
1
by: silentbuddha | last post by:
Hi, I am currently having some difficulties with this sunroutine that I created. My 2 dimensional array is empty. - This code is within my UserForm1 - this sub is suppose to first select the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.