Haystack and needle :)

Hi Guys,

I’m trying to memorize most of the PHP string and array functions, and trying not to refer to PHP manual all the time :rofl:. The problem is, some of the functions takes haystack as the first parameter and takes needle as the second parameter, on the other hand, many functions takes needle as the first parameter and haystack as the second parameter, any advice how can we recognize these without referring to PHP manual every time :slight_smile:

I think its pretty hard to memorize php functions i catch my self going to php manual and google all the time to remember the spelling and the order.

I been coding php for like 7yrs now… lol

A question where they ask you the order of args in a string related function?

I don’t remember getting one, not even in all the mock tests I did. Maybe it was just me?

Theres just so much other stuff to get your head round, that really score highly in the ZCE tests. XML, OOP design patterns, Streams (ffs!).

FWIW you’d be better off memorizing the ~80 array functions, just know what they are called and what their subtle differences are. That was one area that has really made me a better PHPer - and they do feature highly in the ZCE.

The ZCE was much like the mocks, lots of sly tricky questions - many of which had a really simple answer - just make sure you get used to passing over them and pick off the easy questions first.

You’ll only get one question concerning that, forget it, move on.

Are you sure Cups?

+1 for Eclipse PDT. Very handy for quickly checking what each function wants in which order. :slight_smile:

Thanks for the replies.

Yes, I do use IDE (PHPED), I am soon taking Zend PHP5 Certification, and I needed to memorize these functions :slight_smile:

A general rule of thumb would be that for array functions, the order is needle, haystack; for string functions, the order is haystack, needle. There are exceptions of course and to save your memorising those, I’ll second the recommendation to use an IDE (or editor) which can give you the parameters as-you-type or at the click of a button/key. (:

Ah, they’re a pain aren’t they!

This is why I believe the PHP function library needs a good rewrite, or at least the older parts of it. Newer functions have more of an order.

Personally, I’d say that your IDE can make a difference. I use eclipse PDT, and all I have to do is type ‘strpos’ then crtl+space, and it opens brackets for me and tells me what the parameter is ($haystack, $needle etc), sometimes with a description of the function too!