Skip to content

Array search path #1

@purencool

Description

@purencool

Issue

There is a need for an "array search path" that can be used to navigate the original array.

Solution

  1. Investigate if this can be integrated into the WorkerArrayStringFinder Class

The example below can be adapted to complete this functionality.

    if(is_array($array) && count($array) > 0) {
      foreach($array as $key => $value) {
        $temp_path = $id_path;
        // Adding current key to search path
        array_push($temp_path, $key);

        // Check if this value is an array
        // with atleast one element
        if(is_array($value) && count($value) > 0) {
          $res_path = self::searchUsingKeyAndValue(
            $search_value, $value, $temp_path);

          if ($res_path != null) {
            return [$res_path];
          }
        }
        else if($value == $search_value) {
          return [join(" --> ", $temp_path)];
        }
      }
    }

    return [];

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions