Table of Contents

## Viewing Arrays in phpLens

If you want to view PHP session variables in phpLens (instead of the results of an SQL statement), we have a solution. Use PHPLensArray( ) instead of PHPLensConnect( ) or PHPLensPConnect( ) to create a phpLens object. This function allows you can pass a PHP array to phpLens for display and editing.

For example:

    <?php
    include_once(PHPLENS_DIR.'/phplens.inc.php');
    session_start();

    $lens = PHPLensArray('some_lens_id', array('field1'=> 'My name', 'field2' => 9999) );
    $lens->Render();
    ?>

Will display the standard phpLens screen:

All changes made to this array will be saved in the session variable array $ARRAY_some_lens_id. If you want to reload the data array and lose all changes, call

    PHPLensArrayReset('some_lens_id);

Source code for these functions can be found phplens-common.inc.php.

Limitations

Most phpLens properties can be used, except that you cannot delete nor create new records. The spEdit property is used internally to manage this data, so do not modify this property.

### Reference

function &PHPLensArray($id,$data,$types=false,$cols=false,$lang=PHPLENS_LANG_DEFAULT)

Returns: A phpLens object or false on failure.

- $id: The standard phpLens id, which can be up to 38 characters and must consist of only characters permitted in a PHP variable name.
- $data: The data array, where the keys are the field names, and the values the field data. If the session variable ARRAY_$id is defined, then that session variable is used and $data is ignored.
- $types: Array consisting of data types for the data array using standard ADOdb conventions (C: character, etc).
- $cols: Array holding the field names, replacing the keys of $data.
- $lang: The standard language constants used in phpLens.

Example:

    $id = 'MY_ID';
    $data = array('Jacky', 'Chan','1954-12-30', 180);
    $types = array('C',    'C',    'D'        , I);
    $cols = array('firstn','lastn','bday',    ,'height');
    $lens = PHPLensArray($id, $data, $types, $cols);

function PHPLensArrayReset($id)

This deletes the ARRAY_$id session variable, so that the $data array in PHPLensArray( ) is reloaded.

- $id: The standard phpLens id, which can be up to 38 characters and must consist of only characters permitted in a PHP variable name.