Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <?php
  2.  
  3. $data[] = [
  4. 'sponsor_id' => 2,
  5. 'enroller_id' => 4,
  6. ];
  7. //using [] after $data will concatenate otherwise override
  8. $data[] = [
  9. 'sponsor_id4' => 2,
  10. 'enroller_id5' => 4,
  11. ];
  12.  
  13. //Following above there are two arrays in one array
  14.  
  15.  
  16. print_r($data);
  17. echo "<br />";echo "<br />";echo "<br />";
  18. //To make it one array - so that new values add as an index
  19. $data3 = [
  20. 'sponsor_id' => 2,
  21. 'enroller_id' => 4,
  22. ];
  23. $my_array1 = array("sponsor_id2" => 4 );
  24. $my_array2 = array("enroller_id3" => 5);
  25.  
  26. $res = array_merge($data3, $my_array2, $my_array1);
  27.  
  28. print_r($res);
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement