strings and {...}

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael G

    strings and {...}

    Is there something build into php where {0} or {1} means something?

    For example,

    SELECT * FROM table1 WHERE col1 = {0} AND col2 = {1};

    Mike



    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
  • ZeldorBlat

    #2
    Re: strings and {...}

    > SELECT * FROM table1 WHERE col1 = {0} AND col2 = {1};

    Umm...that's SQL, not PHP. However, PHP does use curly braces for
    things other than blocks of code:



    One thing they can be used for is addressing strings as if they were
    arrays. The number inside the {} indicates which character
    (zero-indexed) you want to get at. So:

    $s = 'Hello';
    $s{0} = 'f';
    echo $s;

    will output 'fello'.

    Comment

    • Kimmo Laine

      #3
      Re: strings and {...}

      "Michael G" <mike-g@montana.com> kirjoitti
      viestissä:11261 08002_15849@spo ol6-east.superfeed. net...[color=blue]
      > Is there something build into php where {0} or {1} means something?
      >
      > For example,
      >
      > SELECT * FROM table1 WHERE col1 = {0} AND col2 = {1};
      >[/color]


      curly braces do have a special meaning inside a string. see php manual
      chapter on strings, especially the paragraphs about simple syntax and
      complex (curly) syntax.

      --
      SETI @ Home - Donate your cpu's idle time to science.
      Further reading at <http://setiweb.ssl.ber keley.edu/>
      Kimmo Laine <eternal.erecti onN0@5P4Mgmail. com>


      Comment

      Working...