While it may certainly seem "lazy" I spend a large portion of my time in javascript and I like the syntax for arrays.

I cant seem to figure out if I can "prototype" the array "object" and give it methods that simply returns the appropriate function:

i.e.

$aMyArr = array();
$aMyArr->push($iNum);

where

array->push = function ($Foo) { if isset($Foo) { this[] = $Foo; }; }; // I am quite aware this is not valid. Demo purposes

if this is possible, is this going to make a large overhead just for ease of use?

The only other thing I can think of doing is making a new class that has one protected var that is an array, and cloning all the methods... which is basically what Im doing, but I don't want to call it class "myArr"... and then I have to make a constructor that will iterate what is passed in... and stuff... :-/

Since array is not a class, I think what you describe in your last paragraph is the way to go.

Whether it's overhead... I wouldn't implement it but if you find this easier/better to use, then why not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.