Guest User

Untitled

a guest
Apr 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. foreach( $_POST as $key => $value ){
  2. if( is_int($key) ) //do something with $value
  3. }
  4.  
  5. if(count($_POST) > 1){ // just a check here.
  6. reset($_POST); // reset the pointer regardless of its position
  7. $second_value = next($_POST); // get the next value, aka 2nd element.
  8. }
  9.  
  10. foreach ($_POST as $k => $v) {
  11. if (substr($k, 0, 3) == 'id_') {
  12. // do stuff
  13. }
  14. }
  15.  
  16. <?php
  17.  
  18. $a = array(
  19. "first key" => "first value",
  20. "second key" => "second value",
  21. );
  22.  
  23. $v = array_values($a);
  24. echo "First value: {$v[0]}n";
  25.  
  26. ?>
  27.  
  28. $ php -f a.php
  29. First value: first value
  30.  
  31. function nth($ary, $n) {
  32. $b = array_slice($ary, intval($n), 1);
  33. return count($b) ? reset($b) : null;
  34. }
  35.  
  36. $foo = nth($_POST, 1);
  37.  
  38. <?php
  39. print_r($_POST);
  40. ?>
  41.  
  42. $vars = $_POST;
  43.  
  44. unset( $vars[ "known variable 1" ] );
  45. unset( $vars[ "known variable 2" ] );
  46.  
  47. foreach($_POST as $key=>$value):
  48. print 'key'.$key.' value'.$value
  49. endforeach;
Add Comment
Please, Sign In to add comment