Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6839869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:46:17+00:00 2026-05-26T23:46:17+00:00

public function filter($index, $value) { if($this->tasks) { foreach ($this->tasks as $id => $t) {

  • 0
    public function filter($index, $value) {
        if($this->tasks) {
            foreach ($this->tasks as $id => $t) {
                if($t->$index != $value) {
                    unset($this->tasks[$id]);
                }
            }
        } else {
            echo "Tasks are empty";
        }
    }

So I am having a problem with the function above searching multidimensional objects. What I mean by that is like these:

$task->form->id
$task->form->type
$task->author->id
$task->fields->[FIELDNAME]->value
$task->form->template->id
$task->id

etc. These are the kinds of fields that need to be accessed. I thought that I could just, in $index, put “form->id” but that didn’t work. For my application, I literally can spell it out. I just don’t want to have to write a function for each to the last, because some of them (as you can see) only need to be on the first level and some need to be all the way down four objects.

Just tell me what more data you need and I will give it. I know every keystroke intimately so it sometimes means I forget to share something.

If you help, thank you so much.

WHAT I DID


Okay so I got it to work but I did something different.

Within the Form class

public function search($value, $type = NULL) {
    if(is_object($this->fields)) {
        foreach($this->fields as $page) {
            foreach($page as $name=>$field) {
                if($name != "pdata") {
                    if ($type != NULL && $field->type == $type && $field->value == $value || $type == NULL && isset($field->value) && $field->value == $value) {
                        return true;
                    }
                } 
            }
            return false;
        }
    } else {
        //Probably corrupted
        return false;
    }
    return false;
}

Outside of it I can just call this function and delete or add based on whether it returns true or false.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:46:18+00:00Added an answer on May 26, 2026 at 11:46 pm
    function array_searchRecursive( $needle, $haystack, $strict=false, $path=array() )
    {
        if( !is_array($haystack) ) {
            return false;
        }
    
        foreach( $haystack as $key => $val ) {
            if( is_array($val) && $subPath = array_searchRecursive($needle, $val, $strict, $path) ) {
                $path = array_merge($path, array($key), $subPath);
                return $path;
            } elseif( (!$strict && $val == $needle) || ($strict && $val === $needle) ) {
                $path[] = $key;
                return $path;
            }
        }
        return false;
    }
    

    OR

    I know you don’t want to write it all out, but I have to say I love the way this is done in the Symfony framework. In symfony you have an Entity class that defines functions to retrieve each piece of information (variable) from a given object.

    One way you could mimic this is to create a base class for tasks that has functions to retrieve each variable you need…such as getTaskId.

    Then you could extend this base class with the one you are working with now. This would give you access to the functions you created to parse your object. Retrieving $task->form->template->id could be as simple as calling the getTemplateId function.

    I know this would probably take longer than what you were looking for, but I hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was following this tutorial when typing up this code: public function search($term){ $filter
I am trying to get this method in a String Filter working: public function
public function init(){ $this->view->user = Zend_Auth::getInstance()->getIdentity(); $this->view->siteName = Zend_Registry::get('config')->site->name; $this->view->menu = $this->_helper->generateMenu(Zend_Auth::getInstance()->getIdentity()); $this->view->slogan =
public function __construct($input = null) { if (empty($input)){ return false; } and then there's
public function configure() { $this->widgetSchema['start_date'] = new sfWidgetFormInput(); $this->widgetSchema['end_date'] = new sfWidgetFormInput(); $this->validatorSchema->setPostValidator( new
Here's my RegisterController: public function saveforminformationAction(){ $request = $this->getRequest(); if($request->isPost()){ //I NEED HELP WITH
I have the following code: public function checkLoginDetails($email, $password) { $select = $this->select ();
I generated with Admin generator this: abstract class autoNewsActions extends sfActions { public function
public function test(){ $data = ORM::factory('testdata')->find_all(); Table::factory() ->set_body_data($data) ->set_row_titles('id') ->set_column_titles(Table::AUTO) ->set_callback('format_row', 'row') ->render(true); $this->template->title
public function bmdToStr(bmd:BitmapData,width:int,height:int):String { var encoder:JPEGEncoder = new JPEGEncoder(); var encBytes:ByteArray = encoder.encode(bmd); return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.