skip to Main Content
$data3 = 'primary_mobile_number, amount, new, hs_analytics_source_data_3';
$data4 = 'amount_in_home_currency, days_to_close, deal_currency_code, hs_acv, hs_all_assigned_business_unit_ids, hs_all_collaborator_owner_ids, hs_all_deal_split_owner_ids, hs_analytics_latest_source, hs_analytics_latest_source_company, hs_analytics_latest_source_contact, hs_analytics_latest_source_data_1, hs_analytics_latest_source_data_1_company, hs_analytics_latest_source_data_1_contact, hs_analytics_latest_source_data_2, hs_analytics_latest_source_data_2_company, hs_analytics_latest_source_data_2_contact, hs_analytics_latest_source_timestamp, hs_analytics_latest_source_timestamp_company, hs_analytics_latest_source_timestamp_contact, hs_analytics_source, hs_analytics_source_data_1, hs_analytics_source_data_2, hs_arr, hs_campaign, hs_closed_amount, hs_closed_amount_in_home_currency, hs_created_by_user_id, hs_date_entered_appointmentscheduled, hs_date_entered_closedlost, hs_date_entered_closedwon, hs_date_entered_contractsent, hs_date_entered_decisionmakerboughtin, hs_date_entered_presentationscheduled, hs_date_entered_qualifiedtobuy, hs_date_exited_appointmentscheduled, hs_date_exited_closedlost, hs_date_exited_closedwon, hs_date_exited_contractsent, hs_date_exited_decisionmakerboughtin, hs_date_exited_presentationscheduled, hs_date_exited_qualifiedtobuy, hs_deal_amount_calculation_preference, hs_deal_stage_probability, hs_deal_stage_probability_shadow, hs_exchange_rate, hs_forecast_amount, hs_forecast_probability, hs_is_closed, hs_is_closed_won, hs_is_deal_split, hs_lastmodifieddate, hs_likelihood_to_close, hs_line_item_global_term_hs_discount_percentage, hs_line_item_global_term_hs_discount_percentage_enabled, hs_line_item_global_term_hs_recurring_billing_period, hs_line_item_global_term_hs_recurring_billing_period_enabled, hs_line_item_global_term_hs_recurring_billing_start_date, hs_line_item_global_term_hs_recurring_billing_start_date_enabled, hs_line_item_global_term_recurringbillingfrequency, hs_line_item_global_term_recurringbillingfrequency_enabled, hs_manual_forecast_category, hs_merged_object_ids, hs_mrr, hs_next_step, hs_num_associated_active_deal_registrations, hs_num_associated_deal_registrations, hs_num_associated_deal_splits, hs_num_target_accounts, hs_object_id, hs_pinned_engagement_id, hs_predicted_amount, hs_predicted_amount_in_home_currency, hs_priority, hs_projected_amount, hs_projected_amount_in_home_currency, hs_read_only, hs_tcv, hs_time_in_appointmentscheduled, hs_time_in_closedlost, hs_time_in_closedwon, hs_time_in_contractsent, hs_time_in_decisionmakerboughtin, hs_time_in_presentationscheduled, hs_time_in_qualifiedtobuy, hs_unique_creation_key, hs_updated_by_user_id, hs_user_ids_of_all_notification_followers, hs_user_ids_of_all_notification_unfollowers, hs_user_ids_of_all_owners, hubspot_owner_assigneddate, primary_mobile_number, dealname, amount, dealstage, pipeline, closedate, createdate, engagements_last_meeting_booked, engagements_last_meeting_booked_campaign, engagements_last_meeting_booked_medium, engagements_last_meeting_booked_source, hs_latest_meeting_activity, hs_sales_email_last_replied, hubspot_owner_id, notes_last_contacted, notes_last_updated, notes_next_activity_date, num_contacted_notes, num_notes, hs_createdate, hubspot_team_id, dealtype, hs_all_owner_ids, description, hs_all_team_ids, hs_all_accessible_team_ids, num_associated_contacts, closed_lost_reason, closed_won_reason';
$data5 = explode(',', $data3);
$data6 = explode(',', $data4);

var_dump(array_diff($data5, $data6));

Why is it including primary_mobile_number in the difference when it is present in both arrays?

2

Answers


  1. When you exclude by , it means all of the names in that string should be like this name1,name2,name3 to work correctly but since you have a space after each comma name1, name2, name3 instead you should exclude them by a comma flowed by a space. ,

    $data5 = explode(', ', $data3);
    $data6 = explode(', ', $data4);
    
    var_dump(array_diff($data5, $data6));
    
    Login or Signup to reply.
  2. As an alternative, you can also use array_map() to apply trim() to every member of the arrays, like so:

    $data5 = array_map('trim', explode(',', $data3));
    $data6 = array_map('trim', explode(',', $data4));
    
    var_dump(array_diff($data5, $data6));
    

    Which will account for the case that the whitespace may not always be consistent.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search