LMSouq
php-dev Open

PHP append one array to another (not array_push or +)

DA
Danil K
1 month ago
3 views
Problem Description
How to append one array to another without comparing their keys? $a = array( 'a', 'b' ); $b = array( 'c', 'd' ); At the end it should be: `Array( [0]=>a [1]=>b [2]=>c [3]=>d )` If I use something like `[]` or `array_push`, it will cause one of these results: Array( [0]=>a [1]=>b [2]=>Array( [0]=>c [1]=>d ) ) //or Array( [0]=>c [1]=>d ) It just should be something, doing this, but in a more elegant way: foreach ( $b AS $var ) $a[] = $var;

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base