Get modified array during loop

I have a two dimensional array that reads values from another array in order to decide on how itself should be altered. That’s 3 loops. The decision-taking is in part handled by a method which further sends relevant arguments to their respective methods in another class.

One of these methods returns a value that relies on precomputed evaluation of the parent object. A JavaScript analogy would be akin to using event delegation to obtain a live list of nodes. This method requires the updated array which unfortunately happens to be locked during the loop transaction.

How may I access the new list without adding an extra loop to the friar? I might add, without hard coding the method in our decision making method. Something like

if ($needLiveList) $nextClass->specificMethod($args)

I could create a new array after traversing array level 1 but my constraints are

  1. it’s pointless if I have to descend another loop just because
  2. My hands are somewhat tied in terms of parameters I can pass to the processing method. Every function in that class is fashioned with the same signature so I can pass in arguments from a central agent.

The implementation below may be hard to follow, that’s why I explained first

	public function formInterface (&$processed, $tools) {

		$cache = [];
		foreach ($tools as $selection => $eq) {
			foreach ($processed as $tea => &$lump) {

				foreach ($lump as $key => &$frequency) {

					preg_match('/(?<![a-z-])(' . $selection . ')([ -].+)?$/i', $key, $match);

					$match = array_filter($match);
					if (!empty($match) && !stripos($key, 'orrect')) { // correct score might hold 1

						if (!isset($match[2]) && $frequency < 7) unset($lump[$key]);

						else {

							if (isset($cache[$match[1]])) $newFreq = $cache[$match[1]];

							else $newFreq = $this->confirmValidity($tools[$match[1]], $tea);

							if (!$newFreq) unset($lump[$key]);

							else {
								$frequency = 10;

								$cache[$match[1]] = 10;

				// $lump = $this->omitRedundant($lump);
		return $processed;

	 * documentation: checks to see if head to head likelihood tallies with current form
	 * @param {condition}:String. calculation
	 * @param {parent}:String. the name of the teams which these predictions are under
	 * @return bool

	private function confirmValidity ($condition, $parent) {

		$args = explode('\\', $condition);

		$equation = $args[0];

		$methodArg = end($args);

		$directives = ['getRes', 'hashmapArg', 'reflect'];

		$ppg = explode('-', $parent)[0];

		$culprit = array_filter($this->origDataSet, function ($fixture) use ($ppg) {
			return $fixture['PPG'] == $ppg;

		$method = $directives[count($args)-1];

		$opts = ['caller' => $this->getHalves()[$parent], 'methodArg' => $methodArg];

		$form = new CurrentForm (array_values($culprit)[0]);

		return $form->$method($equation, $opts); // these methods should probabaly be called from the instance's constructor



// this needs to run after fresh properties have been evaluated. the context object is sealed during the loop
	public function reflect ($eq, $opts) {

		$parent = $opts['caller']; // this is a stale object

		$eq = preg_replace_callback('/\'(.+?)\'/', function ($match) use ($parent) {
			return $parent[$match[1]];
		}, $eq);

		return $this->getRes($eq, $opts);


$tools = [

'key1' => (17 >= 15),

2 => key1 && (14 - 10 == 4)\true // meaning read from the current object

There are people who want to help you who have looked at your post. But it is so convoluted and one would have to study it for an hour to determine what you need and what you are asking. Please if you need help, find a way to simplify what you are asking so you can still get what you need. What is the root question; what is the essence of your problem or of what you want to know.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.