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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:04:23+00:00 2026-05-13T15:04:23+00:00

i m using array_combine() but it display error when in first array there is

  • 0

i m using array_combine() but it display error when in first array there is no value.
how to get rid of this

EDIT:

First array  
Distance_Array
Array
(
    [0] => 
)

School_ID_Array
Array
(
    [0] => 
)
 and i m using
$Coverage_ Array=array_combine($School_ID_Array,$Distance_Array);   

which results

Coverage_ Array
Array
(
    [] => 
)

i want that in first array, if any value is empty , 
then  Coverage_ Array key accept any default key
  • 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-13T15:04:23+00:00Added an answer on May 13, 2026 at 3:04 pm

    Use conditions like this:

    if (isset($some_var_or_array) && !empty($some_var_or_array)) {
        // some code which using $some_var_or_array value(s)
    }
    

    UDATED

    Here the function ArrayCombine(), which get three parameters: two arrays and third – the default parameter. The default parameter value will be set to the empty or nulled first array values:

    function ArrayCombine($array1, $array2, $default = 0)
    {
        foreach ($array1 as $key => $value) {
            if (!isset($value) || empty($value)) {
                $array1[$key] = $default;
            }
        }
        return array_combine($array1, $array2);
    }
    

    Here the example:

    $Distance_Array = array(
        1 => '',
    );
    
    $School_ID_Array = array(
        3 => 4,
    );
    
    $Coverage_Array = ArrayCombine($Distance_Array, $School_ID_Array);
    
    var_dump($Coverage_Array);
    
    /*
        var_dump output:
        array(1) {
            [24]=>
                int(4)
        }
    */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code to get the latest events: <?php $all_events = array(); $ten_events
I am using Array() with each_with_index to output a array with index but I
Is there any speed/space/general performance gains in using array based implementation of a binary
I have two arrays, and I am using array_diff_assoc() to get the difference, but
I tried using Kohana/ORM on my localhost xampp and i get the following error
I want to do something like bellow using php: $turl=array(trim($params->get('c2'))); $tname=array(trim($params->get('cn2'))); and want to
I'm using Set class of Cakephp to format the find returned array but cannot
When using the dollar-dollar-function in prototype I alway get an array of elements back,
hi guys i have this script but obviously im not using foreach right i
I want to combine two array's, excluding duplicates. I am using a custom class:

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.