Skip to content

Instantly share code, notes, and snippets.

@davidwood
Created May 24, 2011 16:10
Show Gist options
  • Save davidwood/989019 to your computer and use it in GitHub Desktop.
Save davidwood/989019 to your computer and use it in GitHub Desktop.
Single line access to array value
<?php
function returnArray() {
return array('item1', 'item2', 'item3');
}
function array_value(&$arr, $index) {
return $arr[$index];
}
echo array_value(returnArray(), 1);
?>
@getify
Copy link

getify commented May 24, 2011

array_pop(array_slice(returnArray(),$_IDX_,1))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment