如何在一行中编写此表达式,codeigniter

i have a piece of code , i want to get the result in on line

    $lang = $this->config->item('email');
    echo $lang['support_email'] ; die;

when i var_dump $lang the result

array(11) {
  ["useragent"]=>
  string(11) "CodeIgniter"
  ["mailpath"]=>
  string(17) "/usr/bin/sendmail"
  ["protocol"]=>
  string(4) "mail"
  ["smtp_host"]=>
  string(9) "localhost"
  ["smtp_user"]=>
  string(0) ""
  ["smtp_pass"]=>
  string(0) ""
  ["smtp_port"]=>
  string(2) "25"
  ["system_email"]=>
  string(21) "noreply@elephanti.com"
  ["help_email"]=>
  string(18) "help@elephanti.com"
  ["inquiries_email"]=>
  string(23) "inquiries@elephanti.com"
  ["support_email"]=>
  string(21) "support@elephanti.com"
}

i tried

echo $this->config->item('email')['support_email']

and

echo echo `$this->config->item('email')->support_email 

please help.............

You can only do echo $this->config->item('email')['support_email'] in PHP 5.4+

Otherwise the best you can do is:

$lang=$this->config->item('email');echo $lang['support_email'];exit;

Or write a custom function to do it for you.

But then ask yourself, why must you do this on one line...?

Try:

foreach($lang as $key=>$val)
{
  if($key == "support_email")
  {
    echo $val;
  }
}

echo $this->config->item('email')['support_email']

This actually works in PHP > 5.4. In older versions, it's not possible to do it in one statement, so you'll have to store the array in a separate local variable. You can create a function that will retrieve a value like so:

 <?php
 function array_get( array $array, $index ) {
    return isset( $array[$index] ) ? $array[$index] : false;
 }

 echo array_get( $this->config->item( 'email' ), 'support_email' );

But that's useless really. Any particular reason you want to do it in one line?

$lang = $this->config->item('email', 'support_email');

From the doc:

http://codeigniter.com/user_guide/libraries/config.html

// Retrieve a config item named site_name contained within theblog_settings array`

$site_name = $this->config->item('site_name', 'blog_settings');