Jump to content

Populate array from variable with each loop


UG1234

Recommended Posts

Hi, can you guys please help. Basically I have populated a variable from lotus database however i want to create a loop to populate an array from the variable,  however I just can't get it to work. Here's what I have so far. I have tried 'foreach' and explode functions however just can't get it to work.

 

Any help appreciated. Cheers

 

//get first document in the view

$doc = $view->getFirstDocument();

 

//counter for array

$counter=0;

 

//createarray

$fieldvalue = array();

 

//loop

while (is_object($doc)) {

 

//get handle to a field called $field

$field=$doc->GetFirstItem("[field from db");

 

//get text value of the fieldstring

$fieldstring=$field->text;

 

//echo $fieldvalue;

$fieldvalue["$counter"] = array("$fieldstring");

 

$counter++;

$doc = $view->getNextDocument($doc);

}

 

 

$session = null;

 

?>

Thanks for the reply. Unfortunately  I don't think its worked. I added

 

"print $fieldvalue;" after the loop and I just have an empty array. The result I am hoping for is:

 

$fieldvalue[0] = contain $fieldstring value from 1st loop

$fieldvalue[1] = contain $fieldstring value from 2nd loop

$fieldvalue[2] = contain $fieldstring value from 3rd loop 

etc, etc.

 

Any comments appreciated cheers

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.