SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrays, quotes, or single quotes, or no quotes?

    Hi,

    I'm sure I've seen someting about this before in the forum, but can't remember the outcome. When using arrays, should one use:

    PHP Code:
    myarray["value"
    or
    PHP Code:
    myarray['value'
    or
    PHP Code:
    myarray[value
    ??

    Thanks
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    One should never use
    PHP Code:
    myarray[value
    since you could never be absolutely sure what value was. As to the other two methods, I have used both but tend to stick with
    PHP Code:
    myarray['value'
    as (I believe) it is marginally faster since PHP doesn't have to check inside the quotes as to whether a variable exists therein.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    grassy a s s (mmmmm, i'm bi-lingual, and i never even knew it)
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    More info here

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still, you can't find anything in this thread anymore, there is just too much information there.
    I think it should be cleaned up of the discussions and leave one post for each tip.

    Just an idea though...
    - website

  6. #6
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by website
    Still, you can't find anything in this thread anymore, there is just too much information there.
    I think it should be cleaned up of the discussions and leave one post for each tip.

    Just an idea though...
    The relevant bit is in the orignal post by DrLarry. Personally, I think teh discussion is good as context; it lets you take a look at several viewpoints over best practices.
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  7. #7
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, ok, but there is just too much, the main points should be summed up and perhaps placed in DrLarry's post, just so you can get a quick look and see how it should be done, the 'result' of the thread... then if you have further interest in reading why then you could scroll down the pages and read the posts.

    Just the rest of the idea though...
    - website


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •