Page 1 of 1

Using array value as key, only the first letter.

Posted: Mon Mar 25, 2013 1:19 pm
by EcazS
I have a weird issue, I have had this issue before but I can't remember how I solved it. I have this code,
$this->test = $library["example"];
// test is now an array containing some information

// set key to test
$this->key = "test";

// $items[0] is set to "example"
print_r($this->key[$items[0]]);
But this does not work, it gives me this error
Warning: Illegal string offset 'example' in C:\wwwroot\EXP\core\class\char.class.php on line 89
t

Notice the trailing "t" at the end of the warning? That is always the first letter of the key, if I change the key to "xp" it gives me "x".

But if I change it to this, then it works.
print_r($this->test[$items[0]]);
How do I solve this?

Re: Using array value as key, only the first letter.

Posted: Mon Mar 25, 2013 2:56 pm
by EcazS
Solved.

I by mistake set the variable to a string instead of a variable >_>