Guest User

Untitled

a guest
Oct 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. <?php
  2. $array = array(
  3. "1" => "android",
  4. "2" => "apple",
  5. "3" => " iphone 6",
  6. "4" => " iphone 5",
  7. "5" => " iphone",
  8. "6" => "blackberry",);
  9.  
  10. $phone=[];
  11. foreach($array as $value){
  12. if(substr($value, 0, 1)==' '){
  13. $apple=(end($phone));
  14. $string=[$apple=$apple.$value];
  15. }else{
  16. $phone[]=$value;
  17. }}
  18. ?>
  19.  
  20. var_dump ($apple=$apple.$value);
Add Comment
Please, Sign In to add comment