1 Nov 2009

PHP

Posted by gavin

Arrays

To get the first element of an array (useful for associative arrays):

$array = array( 'key1' => 'value1', 'key2' => 'value2');
$firstElement = reset($array);

To get the first key of an array:

$array = array( 'key1' => 'value1', 'key2' => 'value2');
$firstKey = key(reset($array));
VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
  • Print
  • Add to favorites
  • Facebook
  • StumbleUpon
  • del.icio.us
  • FriendFeed
  • Twitter
  • Digg

Leave a Reply

Message:

  • Browse

    or
  • Latest Content

  • Gallery

    Graters are slow... Up to Ore Gap DSCF2535 (2) IMG_6719
  • Tags

  • RSS<img src="http://www.gavinwillingham.com/wp-content/plugins/twitter-widget-pro/twitter_logo_s.png" height="21" width="92" alt="twitter logo" />

  • Comments