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($spa w_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.
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($spa w_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.
Comment