note 26808 modified in function.array-keys by danbrown
| From: | danbrown@php.net | Date: | Wed, 25 Aug 2010 01:50:59 +0000 |
| Subject: | note 26808 modified in function.array-keys by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172017@lists.php.net to get a copy of this message | ||
If you receive a bunch of variables and like to change most of them (or all of them for that
matter), you can do something like this: (data has been sent to a page with POST)
<?php
$allKeys = array_keys($HTTP_POST_VARS);
for ($i=0;$i<count($allKeys);$i++)
{
$$allKeys[$i] = strtoupper($HTTP_POST_VARS[$allKeys[$i]]);
}
?>
This makes caracters (a-z) uppercase. This is just one way to use it, ofcourse.
Hope this helps someone understand the way to use array_keys() or give any ideas. :)
--was--
If you receive a bunch of variables and like to change most of them (or all of them for that
matter), you can do something like this: (data has been sent to a page with POST)
<?
$allKeys = array_keys($HTTP_POST_VARS);
for ($i=0;$i<count($allKeys);$i++)
{
$$allKeys[$i] = strtoupper($HTTP_POST_VARS[$allKeys[$i]]);
}
?>
This makes caracters (a-z) uppercase. This is just one way to use it, ofcourse.
Hope this helps someone understand the way to use array_keys() or give any ideas. :)
http://php.net/manual/en/function.array-keys.php