Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Problem with Classes

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35066
    gilgimech
    Participant

    I’m having a problem with two classes working together

    These are my classes


    class calssOne {

    public function functionOne(){
    $myArray = array(
    array( 'std' => '' , 'type' => 'checkbox' , 'pre' => 'prefix_' , 'name' => 'theName' )
    );

    foreach($myArray as $value){
    $foreachArray = array( $value,$value => $value);
    }
    }
    }

    class classTwo {
    public function functionTow() {

    $get_class = new calssOne();
    $myOptions = $get_class -> functionNameOne();

    if (isset($_POST)) {
    if (isset($_POST)) { //
    foreach loop
    $myOptions = apply_filters('prefix_theName_save_pre', $_POST);
    }
    }
    }
    }

    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?

    #90252
    gilgimech
    Participant

    Yes it is for a WordPress plugin, but I’m just trying to learn OOP. It’s based off a this tutorial.

    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.

    #90254
    gilgimech
    Participant

    Basically I want the foreach to do is loop this.

    if (isset($_POST)) {
    $myOptions = apply_filters('prefix_theName_save_pre', $_POST);
    }

    for each item in $myArray.

    I removed the $myOptions var and it doesn’t.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.