FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to construct an associative and numeric indexable array
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: How to construct an associative and numeric indexable array [message #178276 is a reply to message #178274] Sat, 26 May 2012 04:04 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 5/25/2012 11:09 PM, Leonardo Azpurua wrote:
> "Jerry Stuckle"<jstucklex(at)attglobal(dot)net> escribió en el mensaje
> news:jpp6u3$l9u$1(at)dont-email(dot)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(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Overriding PHP INI Setting session.use_trans_sid=0
Next Topic: Saving a three-dimensional array to the mysql database.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 07:18:04 GMT 2024

Total time taken to generate the page: 0.04030 seconds