Having problem during coding, was thinking how to join an array after results returned from several database tables, then Sogua found a function for me call array_merge() in PHP. After studied PHP documentation and I have found PHP built-in a lot cool array functions such as array_reverse, array_flip, array_diff_assoc and etc. These array functions have helped me a lot on array() manipulations.
Let talk about array_merge, let say you have done few query from differrent database tables, and you want all the returned results store into an array, here is simple example.
Assume you have array as below;
$takizo = array("Company Name"=>"Takizo", "Company Tel"=>"1234", "Country"=>"Malaysia");
$paulooi = array(”DOB”=>”09091999″, “POB”=>”AS”, “web”=>”paulooi.com”, );
$food = array(”Chinese”=>”Bak Kut Teh”, “Indian”=>”Tosai”, “Malay”=>”Nasi Lemak”);
Those arrays above are query from different database tables(after runing few time pg_query), but you want to put all in one array, this will save you.
$paul_details = array_merge($takizo, $paulooi, $food);
print_r($paul_details);
It will returns,
Array
(
[Company Name] => Takizo
[Company Tel] => 1234
[Country] => Malaysia
[DOB] => 09091999
[POB] => AS
[web] => paulooi.com
[Chinese] => Bak Kut Teh
[Indian] => Tosai
[Malay] => Nasi Lemak
)
Hope this helps!