Welcome Guest, Not a member yet? Register   Sign In
PHP Array Question
#2

[eluser]usmc[/eluser]
[quote author="CodeIgniterNewbie" date="1213686773"]I have a method that returns an array. Is there a way to access a specific element of that returned array? For example:

Code:
// returns the array, but I only want, say, the value of the second element
$MyObject->GetMyArray();

// I'd like to do something like this, but it doesn't work:
$MyObject->GetMyArray[1];
[/quote]

you can do any one of these (and so much more)
Code:
$array = $MyObject->GetMyArray();

$you_are_killing_me_smalls = $array[1];

//or

//(inside class/method)

function GetMyArray()
{
  //form your array however you do it
  $getmearraysomeway = array();
  $this->arrayContainer = $getmearraysomeway;
}

$MyObject->GetMyArray();
$array = $MyObject->arrayContainer[1];


Messages In This Thread
PHP Array Question - by El Forum - 06-16-2008, 08:12 PM
PHP Array Question - by El Forum - 06-16-2008, 08:56 PM
PHP Array Question - by El Forum - 06-16-2008, 09:38 PM
PHP Array Question - by El Forum - 06-17-2008, 06:46 PM
PHP Array Question - by El Forum - 06-17-2008, 07:17 PM
PHP Array Question - by El Forum - 06-17-2008, 09:25 PM
PHP Array Question - by El Forum - 06-17-2008, 09:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB