|
-
Sep 11th, 2008, 02:20 PM
#1
Thread Starter
Frenzied Member
Multidimensional Array
I have an array, I want to be able to access the array like this...
But it wont let me access the array, any reason why? I have to be able to access using its name, author, title etc.
Code:
(
[0] => Array
(
[0] => author
[1] =>
[2] =>
[3] => 1
)
[1] => Array
(
[0] => year_of_publication
[1] =>
[2] =>
[3] => 1
)
[2] => Array
(
[0] => title
[1] => <em>
[2] => </em>
[3] => 1
)
[3] => Array
(
[0] => edition
[1] =>
[2] =>
[3] =>
)
[4] => Array
(
[0] => publisher
[1] =>
[2] =>
[3] => 1
)
)
-
Sep 11th, 2008, 03:14 PM
#2
Re: Multidimensional Array
The array is an indexed array and therefore must be accessed with indexes i.e: 0,1,2,3 . It is difficult from what you have shown above where the data has come from. Is it a regular expression?
-
Sep 11th, 2008, 03:16 PM
#3
Thread Starter
Frenzied Member
Re: Multidimensional Array
I physically make the array further up in the script, here it is...
Code:
// field, prefix, suffix, required
$book = array(
array('author', '', '', true),
array('year_of_publication', '', '', true),
array('title', '<em>', '</em>', true),
array('edition', '', '', false),
array('publisher', '', '', true)
);
-
Sep 11th, 2008, 03:19 PM
#4
Re: Multidimensional Array
Author is a key. So use the => operator to specify this in your top level array:
Code:
$book = array (
'author' => array('','',true) ...
...
...
-
Sep 11th, 2008, 03:22 PM
#5
Thread Starter
Frenzied Member
Re: Multidimensional Array
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|