PHP Array vs Object Array
Posted: Mon May 29, 2006 10:19 am
I was thinking about what a blogger said about why someone hasn't already made an Array Object for PHP since the 'array functions names are not uniformed.' However, my first response was that anyone who is a PHP coder and using arrays can pick up the built-in functions and once you know the function and hone the skill and love for the function then there is little anyone can do to move you away. Until you read something or find code that says otherwise.
Also, the PHP functions are with almost every PHP version, so you don't need to include a class and make sure that all of the developers know how to use it. ArrayObject still blows my mind in its implementation and its use.
The thought did stay in the back of my mind, chewing and scratching its way forward (much like the bastard that suggested I shave 'that' area ending in the same results).
The issues
The speed of the Array object over the native array and functions.
The container for the built-in functions as class methods, do you change the name or do you alias and add support for the other?
Possible in PHP 5
While I have created code that looked like arrays, I have the issue of whether or not you return the scalar or array. I did think of having a stop key to determine whether or not to return the value or to return the arrayobject.
So I think I could implement something that performs similar to the way PHP native array performs. I thought Arrays acted differently, so I was surpised when it was also limited as is SPL ArrayAccess.
The Question
Would this be a good idea? I don't think so, but I'm still going to implement it so that I can get it off my mind.
Also, the PHP functions are with almost every PHP version, so you don't need to include a class and make sure that all of the developers know how to use it. ArrayObject still blows my mind in its implementation and its use.
The thought did stay in the back of my mind, chewing and scratching its way forward (much like the bastard that suggested I shave 'that' area ending in the same results).
The issues
The speed of the Array object over the native array and functions.
The container for the built-in functions as class methods, do you change the name or do you alias and add support for the other?
Possible in PHP 5
While I have created code that looked like arrays, I have the issue of whether or not you return the scalar or array. I did think of having a stop key to determine whether or not to return the value or to return the arrayobject.
Code: Select all
<?php
$array['test'] = 'one'; // Hides help, continue, and parity
$array['test']['help'] = 'me';
$array['test']['continue'] = 'maybe';
$array['test']['continue']['maybe'] = 'okay do it'; // Fails
$array['test']['parity'] = '0';
$array['script'][] = 0;
$array['script'][] = 1;
$array['script'][] = 2;
var_dump($array);
?>The Question
Would this be a good idea? I don't think so, but I'm still going to implement it so that I can get it off my mind.