Login Retreive lost passwordRegister
Search

Manual  /  Functions  /  Data handling  /  GetAsArray

(Since version FH3-v1.2)

GetAsArray
GetAsArray (
string $datefield
)

Arguments:

Name Description
$datefield The datefield where you want the values from

Description:

This function returns the value of a date field as an array. The array will have three items:

Array (
  0 => year,
  1 => month,
  2 => day
)


See example below.

Example

<?php

// include the class
include('FH3/class.FormHandler.php');

// new form object
$form = new FormHandler();

// datefield
$form -> dateField'Date''date' );

// only when the form is posted..
if( $form -> isPosted() )
{
    
// get the value from the field 
    
list( $year$month$day ) = $form -> getAsArray'date' );

    echo 
    
"Day: "$day ."\n".
    
"Month: "$month ."\n".
    
"Year: "$year ."\n";
}

// submitbutton
$form -> submitButton();

// which function to run when the form is correct
$form -> onCorrect'doRun' );

// display the form
$form -> flush();

// the function which is called when the form is correct
function doRun$data )
{
    
// do something here..
    
echo "Selected date: "$data['date'] ."\n";
}

?>

See also: DateField  |  jsDateField

Latest change: 05 March 10 / 08:51

Comments

powered by PHP-GLOBE   © 2004 - 2024 FormHandler. All rights reserved.   -   Open source license