/    Sign up×
Community /Pin to ProfileBookmark

using sqlsrv_fetch_array() to build an array of query results

I’m sick of copy/pasting a bunch of code every time I access a database. To get around that, I’m building a small data access library, but I’m having trouble getting my array to look right. I need a multi dimensional array, and would prefer that it’s not an array of arrays (which is what I currenly have).

Here is what i have:

[CODE]
while( $row = sqlsrv_fetch_array( $queryResults, SQLSRV_FETCH_ASSOC))
{
array_push($allResults,$row);
}
[/CODE]

^ This gives me an array of arrays, how can I get a multi dimensional array that isn’t an array of arrays so I can get values by echo($environments[0,3]); for example?

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @mcru spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...