|
|
| barret bonden 2006-01-10, 7:01 pm |
| having trouble with array of this design
$directory_tree[] = array(
'path' => "test path",
'name' => "test name");
all my efforts at getting at the data don't work ...
//print( $directory_tree["path"]) ;
//print( $directory_tree[0]) ;
print( $directory_tree['path'][0]) ;
| |
|
| barret bonden wrote:
> having trouble with array of this design
> $directory_tree[] = array(
> 'path' => "test path",
> 'name' => "test name");
>
> all my efforts at getting at the data don't work ...
>
> //print( $directory_tree["path"]) ;
> //print( $directory_tree[0]) ;
> print( $directory_tree['path'][0]) ;
>
>
Try:
print($directory_tree[0]['path']);
Zilla.
| |
|
| barret bonden wrote:
> having trouble with array of this design
> $directory_tree[] = array(
> 'path' => "test path",
> 'name' => "test name");
>
> all my efforts at getting at the data don't work ...
>
> //print( $directory_tree["path"]) ;
> //print( $directory_tree[0]) ;
> print( $directory_tree['path'][0]) ;
>
>
Try:
print($directory_tree[0]['path']);
Zilla.
| |
| Janwillem Borleffs 2006-01-10, 7:01 pm |
| barret bonden wrote:
> having trouble with array of this design
> $directory_tree[] = array(
> 'path' => "test path",
> 'name' => "test name");
>
> all my efforts at getting at the data don't work ...
>
> //print( $directory_tree["path"]) ;
> //print( $directory_tree[0]) ;
> print( $directory_tree['path'][0]) ;
>
Assuming $directory_tree has only one element, which is an associative array
containg a 'path' key, you would do:
print $directory_tree[0]['path'];
See http://www.php.net/manual/ and http://www.php.net/array for more info.
JW
| |
|
| Sorry for the double post... Won't happen again.
Zilla.
| |
| John Murtari 2006-01-10, 7:01 pm |
| "barret bonden" <arthur@networks-cc.com> writes:
> having trouble with array of this design
> $directory_tree[] = array(
> 'path' => "test path",
> 'name' => "test name");
>
> all my efforts at getting at the data don't work ...
>
> //print( $directory_tree["path"]) ;
> //print( $directory_tree[0]) ;
> print( $directory_tree['path'][0]) ;
>
>
Okay, your big problem was the [] in
the variable name, the following works fine.
The second print gets you the first character.
$directory_tree = array(
'path' => "test path",
'name' => "test name");
print( $directory_tree["path"]."\n") ;
print( $directory_tree['path'][0]."\n") ;
--
John
________________________________________
___________________________
John Murtari Software Workshop Inc.
jmurtari@following domain 315.635-1968(x-211) "TheBook.Com" (TM)
http://thebook.com/
| |
| barret bonden 2006-01-10, 7:01 pm |
| Got it. Thank you all.
( Makes sense. What a joy of a language ~ ASP and VB.NET have been driving
me nuts)
"Zilla" <mail.is.not@an.option> wrote in message
news:43C42721.9070009@an.option...
> barret bonden wrote:
>
> Try:
>
> print($directory_tree[0]['path']);
>
> Zilla.
| |
| Jim Michaels 2006-01-17, 3:55 am |
| maybe what you were tryiong to do was
$directory_tree = array(
'path' => "test path",
'name' => "test name");
instead. then you don't need the [0].
[] adds a new array index at <count++> for the newly assigned item. if the
variable didn't exist before, it starts with [0] and increments count after
that.
with the above assignment, you can add all the new items you want by just
assigning them. $directory_tree['fuzz']="blah";
"barret bonden" <arthur@networks-cc.com> wrote in message
news:EhXwf.81$h_.20@fe11.lga...
> Got it. Thank you all.
>
> ( Makes sense. What a joy of a language ~ ASP and VB.NET have been
> driving
> me nuts)
>
>
> "Zilla" <mail.is.not@an.option> wrote in message
> news:43C42721.9070009@an.option...
>
>
|
|
|
|