0

I try to parse something from a file, and can't get it to work..

If i do:

$idd = 11;
$aInifile = parse_ini_file('status.ini', 'reply');
echo 'test : ' . $aInifile['reply']['11'];

Then i get the correct reply. But if i use:

$idd = 11;
$aInifile = parse_ini_file('status.ini', 'reply');
echo 'test : ' . $aInifile['reply'][$idd];

Then it do not work... So how can i get it working, using the $idd variable?

My .ini file

[reply]
0 = "In progress (a normal message submission, with no error encountered so far)"
10 = "Delivered upstream"
11 = "Delivered to mobile"

Have tried a lot of things, also searched on Google, so betting on help from you guys here!

KjetilP
  • 11
  • 2

1 Answers1

0

The index is a string, so you can do this:

$idd = "11";
...
echo 'test : ' . $aInifile['reply'][$idd];

Note that 11 !== "11"

Ibu
  • 42,752
  • 13
  • 76
  • 103
  • According to [the manual](http://php.net/manual/en/language.types.array.php), "Strings containing valid integers will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer." It's not a strict comparison. http://codepad.viper-7.com/UtLvnw – Travesty3 May 16 '13 at 02:30
  • Yes, $idd = "11"; did the trick.. But the "clue" is that i get $idd out of an page that i "save" to the variable $idd using curl, so is there a way to add "" to the number (ex the number 11)inside the $idd variable? – KjetilP May 16 '13 at 02:38