[eluser]John_Betong[/eluser]
[quote author="xwero" date="1224168440"]What is too complex to understand in the second example?[/quote]
The reason it is too difficult is there are too many variables on the one line.
To achieve the same result I would add an extra line and make the code (for me) easier to read at a glance.
Code:
//==========================================================================
function _myView($msg=array('one', 'two', 'three'), $msg_name='$msg_name not passed') {
$style = 'text-align:left; font-size:1.0em; background:#ccc none; color:#00f;
width:42%; margin:1em auto; border:dotted; font-weight:bold';
echo "<pre style='$style'>";
echo "Function: <b>" .__FUNCTION__ .' : ' .__FILE__ .' line(' .__LINE__ .')</b>' .BR;
echo '<br />';
echo '<b>' .$msg_name .'</b><br />';
print_r($msg);
echo '<br />';
echo "</pre>";
}
//==================================================
function index($start_page=5) {
$glob_partials['title'] = 'My Great Title';
$content_Xwero = array_merge($glob_partials, array('body'=>'long text'));
$content_John = $glob_partials;
$content_John['body'] = 'long text';
// display the results
$this->_myView($glob_partials, '$glob_partials');
$this->_myView($content_Xwero, '$content_Xwero');
$this->_myView($content_John, '$content_John');
die;
}//end test
Here are the results
Code:
Function: _myView : C:\awww\ci_jokes\controllers\joke.php line(35)
$glob_partials
Array
(
[title] => My Great Title
)
Function: _myView : C:\awww\ci_jokes\controllers\joke.php line(35)
$content_Xwero
Array
(
[title] => My Great Title
[body] => long text
)
Function: _myView : C:\awww\ci_jokes\controllers\joke.php line(35)
$content_John
Array
(
[title] => My Great Title
[body] => long text
)