I have a function that comes from DB, which is all data from users of different tables. I am using What I want to do is return only one The problem is that I'm getting errors because I can not just merge more How do I combine all the You use + array_merge () to insert operators or two arrays. + operator: adds elements of the second array to the first array. For the keys present in both arrays, the elements that match the second array will not be taken care of. array_merge (): Add elements of the second array to the first array. If there are elements in both arrays with the same key, the behavior of this function depends on it: (+): Use (array_merge): I hope this Useful for you Ga. PDO and returns the returns for each
SELECT a
associative array .
array with all the information taken from the DB function, then with a large
array with all user data.
arrays or I '
array ? / P>
function userInfo ($ uID, $ pdo) {$ user = PDOselect ('user', '*', array ('id_user' = & gt; $ uID), $ pdo); $ User_registration = PDOselect ('user_registration', '*', array ('id_user' = & gt; $ uID), $ pdo); $ User_addfields_anagraphic = PDOselect ('user_addfields_anagraphic', '*', array ('id_user' = & gt; $ uID), $ pdo); $ User_addfields_legal = PDOselect ('user_addfields_legal', '*', array ('id_user' => $ uID), $ pdo); $ User_addfields_public = PDOselect ('user_addfields_public', '*', array ('id_user' = & gt; $ uID), $ pdo); Returns .....}
// array ([color] => red, [0] = & gt; 2, [1] = & Gt; 4) $ Array1 = array ("color" = & gt; "red", 2, 4); // array ([0] => A, [1] => B, [color] => green, [size] => cycle, [2] => 4 $ array2 = Using the array = array ("A", "b", "color" => gt; green "," shape "= & gt;" circle ", 4);
$ result = $ array1 + $ array2; // $ result: array ([color] => red, [0] = & gt; 2, [ 1] = & gt; 4, [shape] = & gt circle; [2] = & gt; 4)
< Code> $ result = array_merge ($ array1, $ array2); / / $ result: array ([color] = & gt; green, [0] = & gt; 2, [1] => 4, [2] ] => One, [3] => B, [shape] = cycle, [4] = & gt; 4)
No comments:
Post a Comment