 |
|
|
04-17-2009, 07:20 PM
|
Array declaration help.
|
Posts: 626
|
I need to know if the following two statements will accomplish the same thing:
Code:
$installdefs["Mortgages"][][]["from"] = '<basepath>/SugarModules/relationships/layoutdefs/Accounts.php';
Code:
'layoutdefs' =>
array (
0 =>
array (
'from' => '<basepath>/SugarModules/relationships/layoutdefs/Accounts.php',
'to_module' => 'Accounts',
),
),
);
I know that the second will overwrite the WHOLE array. However, if that was the only thing declared for each would it be the same?
I'm asking because I have additional lines that I need to add to a PHP file. The second one is there already. I need to add more values to the array and I wanted to do it using the first method because the 0 => numbers will be different each time.
|
|
|
|
04-18-2009, 12:32 AM
|
Re: Array declaration help.
|
Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
|
Your second code segment seems to be incomplete. The first is equivalent to this:
PHP Code:
$installdefs = array("Mortgages" =>array(array(array("from" => '<basepath>/SugarModules/relationships/layoutdefs/Accounts.php'))));
__________________
Jeremy Miller
Please login or register to view this content. Registration is FREE
|
|
|
|
04-18-2009, 12:38 AM
|
Re: Array declaration help.
|
Posts: 626
|
Quote:
Originally Posted by JeremyMiller
Your second code segment seems to be incomplete. The first is equivalent to this:
PHP Code:
$installdefs = array("Mortgages" =>array(array(array("from" => '<basepath>/SugarModules/relationships/layoutdefs/Accounts.php'))));
|
Sorry, I took only a section of the file. Here it is again:
PHP Code:
$installdefs["layoutdefs"][] = array( 'from' => '<basepath>/SugarModules/relationships/layoutdefs/Accounts.php', 'to_module' => 'Accounts', );
$installdefs["relationships"][] = array( 'meta_data' => '<basepath>/SugarModules/relationships/relationships/accounts_fp__mortgagesMetaData.php', );
$installdefs["language"][] = array( 'from' => '<basepath>/SugarModules/relationships/language/Accounts.php', 'to_module' => 'Accounts', 'language' => 'en_us', );
$installdefs["vardefs"][] = array( 'from' => '<basepath>/SugarModules/relationships/vardefs/Accounts.php', 'to_module' => 'Accounts', );
Is that the same as this:
PHP Code:
$installdefs = array ( 'layoutdefs' => array ( 0 => array ( 'from' => '<basepath>/SugarModules/relationships/layoutdefs/Accounts.php', 'to_module' => 'Accounts', ), ), 'relationships' => array ( 0 => array ( 'meta_data' => '<basepath>/SugarModules/relationships/relationships/accounts_fp__mortgagesMetaData.php', ), ), 'language' => array ( 0 => array ( 'from' => '<basepath>/SugarModules/relationships/language/Accounts.php', 'to_module' => 'Accounts', 'language' => 'en_us', ), ), 'vardefs' => array ( 0 => array ( 'from' => '<basepath>/SugarModules/relationships/vardefs/Accounts.php', 'to_module' => 'Accounts', ), ), );
|
|
|
|
04-18-2009, 12:44 AM
|
Re: Array declaration help.
|
Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
|
No. It's close, though. Let me teach you how to fish now:
PHP Code:
print '<pre>'.print_r($installdefs,true).'</pre>';
that will display the array itself all prettily-formatted for you. You can then see how things vary or if they are equal.
__________________
Jeremy Miller
Please login or register to view this content. Registration is FREE
|
|
|
|
04-18-2009, 01:01 AM
|
Re: Array declaration help.
|
Posts: 626
|
I just used the following code to test it and the resulting arrays look identical to me:
PHP Code:
<?php $installdefs1 = array ( 'layoutdefs' => array ( 0 => array ( 'from' => '<basepath>/SugarModules/relationships/layoutdefs/Accounts.php', 'to_module' => 'Accounts', ), ), 'relationships' => array ( 0 => array ( 'meta_data' => '<basepath>/SugarModules/relationships/relationships/accounts_fp__mortgagesMetaData.php', ), ), 'language' => array ( 0 => array ( 'from' => '<basepath>/SugarModules/relationships/language/Accounts.php', 'to_module' => 'Accounts', 'language' => 'en_us', ), ), 'vardefs' => array ( 0 => array ( 'from' => '<basepath>/SugarModules/relationships/vardefs/Accounts.php', 'to_module' => 'Accounts', ), ), );
$installdefs["layoutdefs"][] = array( 'from' => '<basepath>/SugarModules/relationships/layoutdefs/Accounts.php', 'to_module' => 'Accounts', );
$installdefs["relationships"][] = array( 'meta_data' => '<basepath>/SugarModules/relationships/relationships/accounts_fp__mortgagesMetaData.php', );
$installdefs["language"][] = array( 'from' => '<basepath>/SugarModules/relationships/language/Accounts.php', 'to_module' => 'Accounts', 'language' => 'en_us', );
$installdefs["vardefs"][] = array( 'from' => '<basepath>/SugarModules/relationships/vardefs/Accounts.php', 'to_module' => 'Accounts', );
echo '<pre style="border: 2px solid black; padding: 1em; margin: 20px;>'.print_r(get_defined_vars(),true).'</pre>'; ?>
Last edited by jim.thornton; 04-18-2009 at 01:05 AM..
|
|
|
|
04-18-2009, 01:06 AM
|
Re: Array declaration help.
|
Posts: 744
Name: Mattias Nordahl
Location: Sweden
|
They are.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
Last edited by lizciz; 04-18-2009 at 01:07 AM..
|
|
|
|
04-18-2009, 01:26 AM
|
Re: Array declaration help.
|
Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
|
Thanks Mattias. He's right. I thought your second arrays included the very first at in your original post. That one has an additional array of nesting which was missing. The last 2 are equal.
Sorry about that!
__________________
Jeremy Miller
Please login or register to view this content. Registration is FREE
|
|
|
|
04-19-2009, 03:03 PM
|
Re: Array declaration help.
|
Posts: 626
|
No worries... Thanks for the help!
|
|
|
|
|
« Reply to Array declaration help.
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|