SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member PSDP's Avatar
    Join Date
    Aug 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to access values inside an array itself??

    how is it possible?? it won;t work ..
    Code PHP:
    $txt = array(
        'name' => 'psdp',
        'name2' => $txt['name']
      );

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not create two arrays? Why a self reference?

    This would be possible if you stored the array as a property of an object, and accessed it using $this, I think trying it like that will end up in recursion + fatal errors being thrown.
    Cross browser css bugs

    Dan Schulz you will be missed

  3. #3
    SitePoint Member PSDP's Avatar
    Join Date
    Aug 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SoulScratch View Post
    Why not create two arrays? Why a self reference?

    This would be possible if you stored the array as a property of an object, and accessed it using $this, I think trying it like that will end up in recursion + fatal errors being thrown.
    hi, thanks for your reply. Could you give me an exmaple?
    actually, my code is something like this, but i found many duplicated values..
    Code PHP:
    //this array doesn;t have a name, it's stored in a file to be used using php function include() / require()
    //$txt = require_once('array_file.php');
     
    //array_file.php
    return array(
     
          //shared items
          'label_email_address' => 'Email Address',
          'label_password' => 'Password',
     
          //login-form
          'login' => array(
            'title' => 'Member Login',
            'label_username' => 'Username',
            'label_email_address' => 'Email Address',
            'label_password' => 'Password'
          )
     
      );

    and this is what i want:
    Code PHP:
    //array_file.php
    return array(
     
          //shared items
          'label_email_address' => 'Email Address',
          'label_password' => 'Password',
     
          //login-form
          'login' => array(
            'title' => 'Member Login',
            'label_username' => 'Username',
            'label_email_address' => #same as shared items value [label_email_address]
            'label_password' => #same as shared items value [label_password]
          )
     
      );

  4. #4
    Use The Cloud
    Join Date
    Jan 2006
    Location
    Boise, ID
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do that in two separate assignments.

    PHP Code:
    $foo = array('foo');
    $foo[1] = &$foo[0];

    $foo[0] = 'blue';
    //$foo[1] = 'red';

    print_r($foo); 
    Brad Hanson, Web Applications & Scalability Specialist
    ► Is your website outgrowing its current hosting solution?
    ► PM me for a FREE scalability consult!
    ► USA Based: Available by Phone, Skype, AIM, and E-mail.


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
  •