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

  • Home
  • SEARCH
  • 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 8729321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:48:48+00:00 2026-06-13T08:48:48+00:00

This is the var_dump($options) array (size=4) 0 => string ‘2’ (length=1) ‘parent_2_children’ => array

  • 0

This is the var_dump($options)

array (size=4)
  0 => string '2' (length=1)
  'parent_2_children' => 
    array (size=3)
      0 => string '22' (length=2)
      1 => string '24' (length=2)
      2 => string '23' (length=2)
  1 => string '3' (length=1)
  'parent_3_children' => 
    array (size=3)
      0 => string '26' (length=2)
      1 => string '25' (length=2)
      2 => string '27' (length=2)

What I have tried up to now is

if(!is_null($options))
        {
            foreach($options as $option)
            {
                 if(!array_key_exists('parent_'.$option.'_children',$options))
                 {
                    //if position null output an error
                 }
            }   


        }

Print_r() as requested

Array
(
    [0] => 2
    [parent_2_children] => Array
        (
            [0] => 22
            [1] => 24
            [2] => 23
        )

    [1] => 3
    [parent_3_children] => Array
        (
            [0] => 26
            [1] => 25
            [2] => 27
        )

)
  • 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-13T08:48:49+00:00Added an answer on June 13, 2026 at 8:48 am

    Your code is correct. An additional check on the nature of the key will reduce the execution, since you have to do the processing only for numeric keys.

        if(!is_null($options))
        {
            foreach($options as $key => $option)
            {
                if (is_numeric($key)) {
                     if(!array_key_exists('parent_'.$option.'_children',$options))
                      {
                           print 'parent_'.$option.'_children does not exist';
                       }
                 }
            }   
    
    
        }
    

    To test the code, try the following array :

     $options = array(0 => 2, 'parent_2_children' => array ( 0 => 22, 1 => 24, 2 => 23 ), 1 => 3, 'parent_3_children' => array ( 0 => 26, 1 => 25, 2 => 27 ), 2=>4 ); 
    

    whose print_r output will be :

     Array
    (
    [0] => 2
    [parent_2_children] => Array
        (
            [0] => 22
            [1] => 24
            [2] => 23
        )
    
    [1] => 3
    [parent_3_children] => Array
        (
            [0] => 26
            [1] => 25
            [2] => 27
        )
    
    [2] => 4
    

    )

    and, it will output :

      parent_4_children does not exist
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my string $newPath = '/~new/assets/js/../packages/prettyphoto/js/jquery.prettyPhoto.js'; Now check this output var_dump($newPath); // string(64)
My var_dump is returning this: array(5) { [radioinput]=> string(12) sidebar-left [option1]=> int(0) [sometext]=> string(0)
I have a query that reads like this: $fields = Doctrine_Core::getTable('model_1')->findByColumnId($id); took a var_dump
var_dump of my array shows up like this. I want to get the count
I have an array of profile data I need to validate: $user_group_profiles = $this->input->post('user_group_profiles',
Having an object like this: var a = { b: string, c: function(){ return
I have this: var blockRegEx = new Regex((proc sql;)(.*?)(quit;), RegexOptions.IgnoreCase | RegexOptions.Multiline); but it
I have code like this var MyObj = { f1 : function(o){ o.onmousedown =
I have this var n = ItemList.Select(s => new { s.Vchr, s.Id, s.Ctr, s.Vendor,
I have this: var date = new DateTime(2009, 12, 5); ... ... and need

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.