Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
How to concatenate two arrays in php?

I have two arrays generating from two sql queries as $array_1 and $array_2. both contain [0] indexes. I want to join them with indexes [0],[1] and so on... So can any one help me on how to concatenate two arrays in php

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

array_merge — Merge one or more arrays

Description

array array_merge ( array $array1 [, array $... ] )

Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.

If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.

Values in the input array with numeric keys will be renumbered with incrementing keys starting from zero in the result array.


Zipping arrays:

If you want [0] to be array1[0] and [1] to be array2[0] etc., you can zip the arrays;

Is there a php function like python's zip?

about 4 years ago · Santiago Trujillo Report

0

I guess you are looking for array_merge?

https://www.w3schools.com/php/func_array_merge.asp

In your case: array_merge($array_1,$array_2)

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!