I have to add some elements from an array into another array for a project.
Here's the deal: I have 2 arrays, from 2 tables of a database, which are named $stand and $signal.
$stand is made up of arrays:
$stand = [[id, name, width, length,...], [id, name, width, length,...], ...]
$signal is made up of arrays as well:
$signal = [[id, num, name, adress, ...], [id, num, name, adress, ...], ...]
Each entry of $stand matches with an entry of $signal: the id of an entry of $stand is equal to the number of elements in $signal.
For these entries, I'd like to add the content of the entry of $signal at the end of the entry of $stand.
Here's the code I used, but unfortunately it doesn't work:
foreach ($stand as $st) {
foreach ($signal as $sig) {
if ($st[0] == $sig[1]) {
$st[]=$sig;
}
}
}
$standnot to its elements. Better approach isarray_merge