Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach( $_POST as $key => $value ){
- if( is_int($key) ) //do something with $value
- }
- if(count($_POST) > 1){ // just a check here.
- reset($_POST); // reset the pointer regardless of its position
- $second_value = next($_POST); // get the next value, aka 2nd element.
- }
- foreach ($_POST as $k => $v) {
- if (substr($k, 0, 3) == 'id_') {
- // do stuff
- }
- }
- <?php
- $a = array(
- "first key" => "first value",
- "second key" => "second value",
- );
- $v = array_values($a);
- echo "First value: {$v[0]}n";
- ?>
- $ php -f a.php
- First value: first value
- function nth($ary, $n) {
- $b = array_slice($ary, intval($n), 1);
- return count($b) ? reset($b) : null;
- }
- $foo = nth($_POST, 1);
- <?php
- print_r($_POST);
- ?>
- $vars = $_POST;
- unset( $vars[ "known variable 1" ] );
- unset( $vars[ "known variable 2" ] );
- foreach($_POST as $key=>$value):
- print 'key'.$key.' value'.$value
- endforeach;
Add Comment
Please, Sign In to add comment