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;

 

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.