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 8209371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:41:52+00:00 2026-06-07T09:41:52+00:00

TL;DR I have this data: var_export and print_r . And I need to narrow

  • 0

TL;DR

I have this data: var_export and print_r.

And I need to narrow it down to: http://pastebin.com/EqwgpgAP ($data[‘Stock Information:’][0][0]);

How would one achieve it? (dynamically)


I’m working with vTiger 5.4.0 CRM and am looking to implement a function that would return a particular field information based on search criteria.

Well, vTiger is pretty weakly written system, looks and feels old, everything comes out from hundreds of tables with multiple joins (that’s actually not that bad) etc., but job is job.

The need arose from getting usageunit picklist from Products module, Stock Information block.

Since there is no such function as getField();, I am looking forward to filter it out from Blocks, that is actually gathering the information about fields also.

getBlocks(); then calls something close to getFields();, that again something close to getValues(); and so on.

So…

$focus = new $currentModule(); // Products
$displayView = getView($focus->mode);
$productsBlocks = getBlocks($currentModule, $displayView, $focus->mode, $focus->column_fields); // in theory, $focus->column_fields should/could be narrowed down to my specific field, but vTiger doesn't work that way

echo "<pre>"; print_r($productsBlocks); echo "</pre>"; // = http://pastebin.com/3iTDUUgw (huge dump)

As you can see, the array under the key [Stock Information:], that actually comes out from translations (yada, yada…), under [0][0] contains information for usageunit.

Now, I was trying to array_filter(); the data out from there, but only thing I’ve managed to get is $productsBlocks stripped down to only contain [Stock Information:] with all the data:

$getUsageUnit = function($value) use (&$getUsageUnit) {
    if(is_array($value)) return array_filter($value, $getUsageUnit);
    
    if($value == 'usageunit') return true;
};
            
$productsUsageUnit = array_filter($productsBlocks, $getUsageUnit);

echo "<pre>"; print_r($productsUsageUnit); echo "</pre>"; // = http://pastebin.com/LU6VRC4h (not that huge of a dump)

And, the result I’m looking forward to is http://pastebin.com/EqwgpgAP, that I’ve manually got by print_r($productsUsageUnit['Stock Information:'][0][0]);.


How do I achieve this? (dynamically…)

  • 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-06-07T09:41:54+00:00Added an answer on June 7, 2026 at 9:41 am
    function helper($data, $query) {
      $result = array();
    
      $search = function ($data, &$stack) use(&$search, $query) {
        foreach ($data as $entry) {
          if (is_array($entry) && $search($entry, $stack) || $entry === $query) {
            $stack[] = $entry;
            return true;
          }
        }
    
        return false;
      };
    
    
      foreach ($data as $sub) {
        $parentStack = array();
        if ($search($sub, $parentStack)) {
          $result[] = $parentStack[sizeof($parentStack) - 2];
        }
      }
    
      return $result;
    }
    
    $node = helper($data, 'usageunit');
    print_r($node);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple helper: def printe_result(data) a_var = ('<a href=http://'+data.a_value+'>A</a>' unless (data.a_value.nil? ||
I have an array of profile data I need to validate: $user_group_profiles = $this->input->post('user_group_profiles',
I have this JavaScript code: for (var idx in data) { var row =
i have this jquery code $(#eioShowLink).on('click',function(){ $(#ioEditRelatedConcepts).html(''); $.getJSON(http://localhost/Mar7ba/Ontology/getRelatedConceptsAndRelations/+conceptName+/TRUE, function(data){ var concepts = data[0]; var
I have fit a simple bi-variate VAR model to this data set and I
I have this script: #!/var/home/cherry/opt/perl use Test::More; use DBI; use Test::mysqld; use Data::Dumper; my
Hi I have this code to parse JSON on JQUERY var json_text2 = $.parseJSON('{data:[[1340650436,2.00000],[1340736844,4.00000]],label:Waist
I have this code: $.getJSON(Featured/getEvents, function(data){ $.each(data.events, function(i,event){ var title = event.title.substr(0,20); $(#title-+i).text(Text); if
So I have something like this situation: $(document).on('click', 'a[data-link]', function () { var $this
I have this data in cell A1: Majestic Properties Design District, LLC, Ste. 101,

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.