|  | Posted by Steve on 04/02/07 05:09 
"Steve" <no.one@example.com> wrote in message news:NDRPh.902$%k3.880@newsfe03.lga...
 |
 | "Erik Kullberg" <erik.kullberg@telia.com> wrote in message
 | news:YdKPh.37639$E02.15231@newsb.telia.net...
 || Thanks, Steve,
 || You hae been most helpful!
 || I can pass a one-dim array, but not a two-or-more-dim array - correct?
 ||
 || It΄s about a linear aerodynamic 6 degrees of freedom model. The
 | coefficients
 || (the table elements) are traditionally handled in named chunks of  3, 9
 or
 || the whole batch as one. But the elements also have their own individual
 || names, which leads to my next question:
 || Is it possible to superimpose variable names, so I can point at a certain
 || value with the name that is appropriate according to the context?
 || I cannot find anything about this in the PHP documentation ...
 |
 | no...you can set the name to however many dimensions you want. here's a
 | quick example of superimpositon...you can tell the blank rows in this
 | example where the full number of errors in validation are present. it
 | doesn't quite work for the password matching but i'm not going to take any
 | more time to flesh it out. i think you'll get a good idea of how it works.
 | let me know where you have problems folling it (sorry for the text
 | wrapping...you have to fix that before running it)...
 |
 | <?
 | $cells        = isset($_REQUEST['cells']) ? $_REQUEST['cells'] : array();
 | $columns      = array(
 |                       'NAME'        ,
 |                       'LOGIN'       ,
 |                       'PASSWORD'    ,
 |                       'VERIFY'      ,
 |                       'EMAIL'
 |                     );
 | $columnCount  = count($columns);
 | if (!is_array($cells)){ $cells = array($cells); }
 |
 | function isEmail($email)
 | {
 |  if (!$email){ return false; }
 |  $pattern =
 |
 "/^((\"[^\"]*?\")|([^\(\)\<\>\@\,\;\:\\\"\[\]\s\*\/]+))@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$/si";
 |  return preg_match($pattern, $email);
 | }
 |
 | function isValid($columns, $column, $value, &$error)
 | {
 |  static $password = '';
 |  $error = '';
 |  switch ($column)
 |  {
 |    case 0:
 |    case 1:
 |    case 2: if (!empty($value)){ return true; }
 |            $error = $columns[$column] . ' is required.';
 |            $password = $value;
 |            break;
 
 what a dumbass i was...i just re-read this post. see any difference between
 that case 2 and this?
 
 case 2: $password = $value;
 if (!empty($value)){ return true; }
 $error = $columns[$column] . ' is required.';
 break;
 
 this biggest one is that the latter works. ;^)
 
 cheers.
  Navigation: [Reply to this message] |