class calssOne { public function functionOne(){ $myArray = array( array( 'std' => '' , 'type' => 'checkbox' , 'pre' => 'prefix_' , 'name' => 'theName' ) ); foreach($myArray as $value){ $foreachArray = array( $value['pre'],$value['name'] => $value['std']); } }}class classTwo { public function functionTow() { $get_class = new calssOne(); $myOptions = $get_class -> functionNameOne(); if (isset($_POST['update_options'])) { if (isset($_POST['theName'])) { // -------- foreach loop -------- $myOptions['prefix_theName'] = apply_filters('prefix_theName_save_pre', $_POST['theName']); } } }}
$myOptions = $get_class -> functionNameOne();
$get_class -> functionNameOne();
if (isset($_POST['theName'])) { $myOptions['prefix_theName'] = apply_filters('prefix_theName_save_pre', $_POST['theName']);}
These are my classes
That code works, but I want to make a foreach loop for the if statement with the comment.
Everything I try doesn't work.
Does anyone have any ideas for this?
$myOptions never actually equals anything because functionNameOne doesn't return a value.
So
should probably be or you should return a value from the functionNameOne, which I'm guessing would be the $foreachArray.
What do you want the foreach loop to do anyway. And is this for Wordpress? Because apply_filters() isn't a standard PHP function
The exapmle I'm working off of is here. The person who wrote the tutrial doesn't explain why he used that method, but it does work.
for each item in $myArray.
I removed the $myOptions var and it doesn't.