Helper function for searching indexed submit POST vars
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 18 Mar 2008 14:40:15 +0000 (14:40 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 18 Mar 2008 14:40:15 +0000 (14:40 +0000)
includes/ui/ui_input.inc

index 0831e6103df0fd66369deac64cc2bbc30bfc66d1..2a51d80ffaa35e9d60cade6e3c8530105a806d4b 100644 (file)
@@ -1,5 +1,25 @@
 <?php
 
+//------------------------------------------------------------------------------
+//    Seek for _POST variable with $prefix.
+//    If var is found returns variable name with prefix stripped,
+//    and null or -1 otherwise.
+//
+function find_submit($prefix, $numeric=true) {
+
+    foreach($_POST as $postkey=>$postval ) {
+       if (strpos($postkey, $prefix) === 0) {
+               $id = substr($postkey, strlen($prefix));
+               return $numeric ? (int)$id : $id;
+       }
+    }
+    return $numeric ? -1 : null;
+}
+
+//------------------------------------------------------------------------------
+//
+//     Read numeric value from user formatted input
+//
 function input_num($postname=null) {
        if (!isset($_POST[$postname])) 
          return null;