CalcBuilder Forum

How to get keys as array?

User moon_1193 2013-07-28 21:27:19

How to get matrix's keys as array (as example row's keys)?
Or could I get values from option list as array?
Thank you.

Moonsoft support 2013-07-29 09:39:02

Hello,

How to get matrix's keys as array (as example row's keys)?


You should use array_keys function to get row´s keys as follows :

$keys=array_keys($YOUR_MATRIX_VAR);

You could get more info about this function at: http://www.php.net/manual/en/function.array-keys.php



Or could I get values from option list as array?


To get info from option list you could use:
- $YOUR_OPTION_VAR : contains the values selected
- $YOUR_OPTION_VAR_name : contains the name of the values selected

By now, getting all values of an option list, selected or not, in code is not possible. We suggest you to use matrix or declare in code instead.

Hope this helps. Regards,

User moon_1193 2013-07-29 10:02:30

Thank you. I'm very glad to work with you and your calcbuilder.

User moon_1193 2013-07-29 20:18:58

Hello again.
I know how to get keys of rows.
I was looking for keys of column.
Anyway I will solve by transforming matrix's array.

Moonsoft support 2013-07-30 09:36:53

Hello,

To get the column key you should use:

$column_keys=array_keys(array_shift($YOUR_MATRIX_VAR));

Note that at least one row must be set in matrix.

Regards,

...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!
...
CalcBuilder

Create dynamic calculators

Buy now!