Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question