A
A
Alexander Sobolev2018-10-14 16:09:40
PHP
Alexander Sobolev, 2018-10-14 16:09:40

How to run foreach over two arrays?

- There is an_conditional_logic option containing arrays of the form
$ae_conditional_logic [basename($file)] = ['path' => $file, 'estate_operation' => $estate_operation, 'estate_type' => $estate_type]
- There is a "forms" folder with files.
How to combine checking each file in a folder for existence in option arrays?
In other words, how to combine two foreach:
1) foreach ( glob( plugin_dir_path( __FILE__ )."../forms/*.php" ) as $file )
2) foreach ($ae_conditional_logic as $logic)
How to properly check if there is an array with name $logic[basename($file)] and if there is, then take its value, for example $logic[basename($file)][path], and if not, then execute the function, for example func1()
Confused as much as the brain boils .. help me figure it out, please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jamaludin Osmanov, 2018-10-14
@jamalosm

If you understand correctly, then try this

foreach ( glob( plugin_dir_path( __FILE__ )."../forms/*.php" ) as $file )
{
   if(isset($ae_conditional_logic[basename($file)]))
   {
     //если есть значение
   }
   else
   {
     func1();
   }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question