Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Is there Dictionary Object in PHP

Is there Dictionary Object in PHP

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
csharpphpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    awedaonline
    wrote on last edited by
    #1

    Hi guys; I wish to store KeyValuePair collection as I do in C# or VB.NET. Is there a way to achieve this in PHP and how? Thanks for your cordial supports.

    G 1 Reply Last reply
    0
    • A awedaonline

      Hi guys; I wish to store KeyValuePair collection as I do in C# or VB.NET. Is there a way to achieve this in PHP and how? Thanks for your cordial supports.

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      You can do that using an array:

      <?php
      $dict = array('a' => 1, 'b' => 2, 'z' => 0);
      $dict['c'] = 5;
      $dict['a more complex value'] = array('X' => 'OK');

      foreach($dict as $key => $value)
      echo "$key : $value<br />\n";

      A 1 Reply Last reply
      0
      • G Graham Breach

        You can do that using an array:

        <?php
        $dict = array('a' => 1, 'b' => 2, 'z' => 0);
        $dict['c'] = 5;
        $dict['a more complex value'] = array('X' => 'OK');

        foreach($dict as $key => $value)
        echo "$key : $value<br />\n";

        A Offline
        A Offline
        awedaonline
        wrote on last edited by
        #3

        Thanks Graham. Your solution works. Thanks.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups