Use variable in $data

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
peteraj
Posts: 27
Joined: 2016-02-05 12:25

Use variable in $data

Post by peteraj » 2020-07-16 09:33

Hi,

Is it possible to "index into" the $data['fieldname'] array? I have tried: $data['fieldname[X]'] but it didn't work..

a little example of what I want:

fieldnames = array("fieldname1","fieldname2","fieldname3");

for ($x = 0; $x <= 10; $x++) {
$data( [fieldname[x] ) = something;
}

I have fields both before and after the fields I want to alter, so I would preffer not to loop through all the fields in the table...

I hope you understand my explanation, any help is appriciated, thank you :-)

Kind regards
Peter

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1814
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Use variable in $data

Post by jsetzer » 2020-07-16 12:59

Code: Select all

$fieldnames = ["fieldname1", "fieldname2"];
foreach ($fieldnames as $fieldname) {
  // your code
  // for example
  // $data[$fieldname] = strtoupper($data[$fieldname]);
}
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

peteraj
Posts: 27
Joined: 2016-02-05 12:25

Re: Use variable in $data

Post by peteraj » 2020-07-16 13:54

Cool, as simple as that! Thank you :-)

Post Reply