Implicit Evaluation with PHP Archives: Arrays
· previous page
17 January 2006
Scheme
Update
Alert reader Joshua C. wrote to correct my usage of the terms apply and map. Seems I had them backwards, but they’re fixed now.
I was thinking about Scheme and tried to create some of the more interesting functions in PHP. map came easily:
function map ($fnName, $list) {
$result = NULL;
foreach ($list as $key => $value) {
$result[$key] […]
continue reading... » 0 Comments
30 November 2005
Combining Implicit Evaluation of Objects with Accessing Arrays
It turns out, that while you can preform implicit evaluation of an object, or a variable, or a variable’s associative array members, trying to merge them all has unexpected behavior.
class foo {
var $arr1;
var $arr2;
}
$foo = new foo();
$foo->arr1 = array(5);
$foo->arr2 = array(5);
function accessFirstElement ($object, $property) {
echo $object->$property[0];
}
accessFirstElement ($foo, “arr1″);
In writing this, I would expect PHP to […]

