Sign in to follow this  
Followers 0
simsalabim

IniReadSection - Associative Array

5 posts in this topic

Hey,

I'm reading the content of an ini-File into an array using:

$button1_arr = IniReadSection("settings.ini", "button1")

the settings.ini looks like this:

[button1]
text=Text of Button 1
tip=This will start File 1
link=.\Tools\start.exe ".\Files\Filexy.ppt"

[button2]
text=Text of Button 2
tip=This will start File 2
link=.\Tools\start.exe ".\Files\Fileabc.ppt"

[button3]
text=
tip=
link=

This way I receive an indexed array like $button1_arr[0] $button1_arr[1] $button1_arr[2] and so on ...

How can I "switch" this to an accociative array, so I'd receive somthing like this: $button1_arr['text'] $button1_arr['tip'] ... and so on ...

I hope you understand what I'm talking about ... and thanks in advance ... :-)

Share this post


Link to post
Share on other sites



yes, I did read and experiment with the help-file

... but I still can't see an automated way to create an associative array ...

(The ini-File will be edited manually, so I cannot rely on $button1_arr[1] will always have "text" as $button1_arr[1][0] ... I'd rather like to have $button_arr[1]['text'] ... )

Share this post


Link to post
Share on other sites

yes, I did read and experiment with the help-file

... but I still can't see an automated way to create an associative array ...

(The ini-File will be edited manually, so I cannot rely on $button1_arr[1] will always have "text" as $button1_arr[1][0] ... I'd rather like to have $button_arr[1]['text'] ... )

Then it looks like you will have to translate the array you iniread to a different array with the desired format.

$button1_arr[1][0] = $myArray[1]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0