Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #6197
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: How to construct an associative and numeric indexable array |
| Date | 2012-05-26 00:04 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <jppkou$jug$1@dont-email.me> (permalink) |
| References | <jpp3vi$87f$1@dont-email.me> <jpp6u3$l9u$1@dont-email.me> <jpphes$6iq$1@dont-email.me> |
On 5/25/2012 11:09 PM, Leonardo Azpurua wrote:
> "Jerry Stuckle"<jstucklex@attglobal.net> escribió en el mensaje
> news:jpp6u3$l9u$1@dont-email.me...
>> On 5/25/2012 7:19 PM, Leonardo Azpurua wrote:
>>> Hi,
>>>
>>> The docs for MS's SQLSRV PHP interface sayes:
>>>
>>> "Based on the value of the $fetchType parameter, the returned array can
>>> be a
>>> numerically indexed array, an associative array, or both."
>>>
>>> It might be helpful to have such an array in some other places.
>>>
>>> How is it done?
>>>
>>
>> RTFM:
>>
>> http://us.php.net/manual/en/function.mssql-fetch-array.php
>
> Hi,
>
> As far as I have RdTFM, an array can be indexed either by key values
> $a1 = array("L1" => "a", "L2" => "b");
> or by an integer
> $a2 = array("a", "b");
>
> You can write $a1["L1"], or $a2[0].
>
> Of course, there is no point in writing $a2["L1"], but being able to write
> $a1[0] might certainly come handy at times.
>
> My mention of the SQLSRV/PHP Driver (not to be confused with the "old" mssql
> library) was because it provides the function sqlsrv_fetch_array, that
> returns a row from a data source as an array whose elements may be accessed
> both by their column name or by their ordinal position (minus one) in the
> column list of the query that generated the statement resource.
>
> So, given a statement ($stmt) based on the query SELECT C1, C2 FROM T, and
>
> $row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_BOTH);
>
> both $row["C1"] and $row[0] are acceptable and equivalent.
>
> My question is *not* how to fetch rows from a result set, but how can I
> build an array that allows both ways of indexing.
>
> I know that if I RTFM, think a lot and devote a few hours (or even days) to
> the problem, I might come with some sort of solution.
>
> But it doesn't hurt to ask, just in case somebody has an answer.
>
> Better if it is an answer to the actual question, but everything helps.
>
>
> Thanks!
> --
>
>
OK, you're using the newer functions. Still, RTFM.
http://us3.php.net/manual/en/function.sqlsrv-fetch-array.php
It explains things quite clearly. But if you don't know PHP, then you
need a lot more help than this page.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to construct an associative and numeric indexable array "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-25 18:49 -0430
Re: How to construct an associative and numeric indexable array Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-25 20:08 -0400
Re: How to construct an associative and numeric indexable array "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-25 22:39 -0430
Re: How to construct an associative and numeric indexable array Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-26 00:04 -0400
Re: How to construct an associative and numeric indexable array "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-25 23:57 -0430
Re: How to construct an associative and numeric indexable array Michael Fesser <netizen@gmx.de> - 2012-05-26 13:00 +0200
Re: How to construct an associative and numeric indexable array "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-26 09:13 -0430
Re: How to construct an associative and numeric indexable array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-27 00:31 +0200
Re: How to construct an associative and numeric indexable array "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-05-26 22:14 -0430
Re: How to construct an associative and numeric indexable array Norman Peelman <npeelmandog@cfl.rr.com> - 2012-05-27 12:12 -0400
Re: How to construct an associative and numeric indexable array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-27 19:48 +0200
Re: How to construct an associative and numeric indexable array Norman Peelman <npeelmandog@cfl.rr.com> - 2012-05-29 18:27 -0400
Re: How to construct an associative and numeric indexable array Norman Peelman <npeelmandog@cfl.rr.com> - 2012-05-27 12:03 -0400
csiph-web