PDA

View Full Version : What does this do? (PHP question)


rrottman
01-08-2004, 03:08 PM
I am not new to PHP but can anybody try to explain what this code (extracted from register.php) in vB 3.0 RC2 actually does? Thanks in advance.


$actiontemplates = array(
'requestemail' => array(
'activate_requestemail'
),
'none' => array(
'activateform'
)
);

Xenon
01-08-2004, 03:16 PM
the code just generates a multidimensional array

ie an array called action templates containing two arrays, called requestemail and none.

each of these arrays contains another entry.

the whole structure is used by vb3 to know which templates have to be cached :)

rrottman
01-08-2004, 03:24 PM
the code just generates a multidimensional array

ie an array called action templates containing two arrays, called requestemail and none.

each of these arrays contains another entry.

the whole structure is used by vb3 to know which templates have to be cached :)
Thanks for getting back to me.
So this means PHP create 1 array named $actiontemplates containing 2 array:

- none
- requestemail

"none" contains a single string "activateform" and "requestemail" contains a single string "activate_requestemail"

Is this correct?
How does a statement have to look to access one of the strings?

$actiontemplates=>none[0]

???
Sorry for asking possibly stupid newbie stuff...

Xenon
01-08-2004, 03:29 PM
no, the request-email and the none are array keys, so to access one of the strings you have to use:

$actiontemplates['none'][0] :)

rrottman
01-08-2004, 03:38 PM
Okay. So they are keys but their values are again, array. And I could possibly iterate through the with the following statement?


foreach ($actiontemplates as $key_at => $value_at) {
echo ("$key_at<br>");
foreach ($value_at as $item) {
echo ("...$item<br>");
}
}

Xenon
01-08-2004, 03:44 PM
yes, that should work :)

rrottman
01-08-2004, 03:48 PM
yes, that should work :)
I'm so glad talking to one of the - huh!! - Administrators of this site... :-)
I always wonder whether there would be an option for the vB team to sell some kind of developer network membership on top of the vB license. I would be willing to pay for it. As far as I have seen it in the past, almost everybody gets interested in changing style, editing templates and sooner or later in starting to hack (a nice word for developing, actually).

I strongly feel for some kind of developer documentation. Explaining the basic concepts. How everything ties together. The docs which come with vB2 are - IMHO - way too smallsized for what you need to really work with vB.

I wonder, is there any site out there trying to explain some of the basic concepts? I'm not thinking of a PHP tutorial. I more or less think of something like a concepts guide.

The .php files I've looked in so far (register.php, login.php) seem to follow some basic structure. Including some functions. Registering some templates. Etc. etc. but it's difficult to grasp the concept behind just from focussing on source files.

Do you know any resource? Maybe another thread?
Any hint?!

Xenon
01-08-2004, 03:50 PM
well going through modification hints and tips should help you for the beginning.
Afaik, there is a better documentation planned for vb3, but i don't know how detailed that will be, so we have to wait for gold until we will know exactly :)