Advertisement
Guest User

Untitled

a guest
May 27th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <?php
  2.  
  3. function foo(){
  4.  
  5. $parentArray = array(10, 11, 12, 13);
  6. $arrayValues = array();
  7. $splitArray = array();
  8.  
  9. for($i = 0; $i < count($parentArray); $i++){
  10.  
  11. $checkVarBefore = $parentArray[$i]+1;
  12. $checkVarAfter = $parentArray[$i+1];
  13.  
  14. if($checkVarBefore == $checkVarAfter){
  15. array_push($arrayValues, $parentArray[$i]);
  16. array_push($arrayValues, $parentArray[$i+1]);
  17. $splitArray[] = array($arrayValues);
  18. $arrayValues = array();
  19. }else{
  20. $arrayValues = array();
  21. }
  22.  
  23. }
  24.  
  25. var_dump($splitArray);
  26. }
  27.  
  28. foo();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement