Jump to content

Recommended Posts

For decades I have lain awake at night pondering this major conundrum.

Why do PDO::FETCH_BOTH and mysqli->fetch_array() exist? Surely one either wants an associative array or, occasionally, a numerically indexed array?

Further, given their uselessness, why the hell are they the default?

Can anyone enlighten me as to their raison d'être?

Link to comment
https://forums.phpfreaks.com/topic/317197-one-of-lifes-big-questions/
Share on other sites

Presumably both of them do so to match the original mysql, whose fetch_array returned the combined form. And I'm going to guess it did out of some sense of "maximum usefulness, minimum effort": call the thing that returns an array and you can use it however you want. $_REQUEST will have come out of that same sort of mentality too, back when PHP was treated more like a templating system than a programming language.

It's a great question.  I have to think that it was extra work to create the associative array version, so it never really made a lot of sense why having two versions of the same data returned in the same array, would be the default.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.