Podio-PHP not reading array from while-loop correctly
I'm using Podio podio-php for my API to save data from a form to Podio and I haven't had any problems other than this small but annoying one. When I use $visit_arr
-array the fields in Podio are empty, but when I use a hand-created array $visit_array_with_manual_values
it works fine. When I print the arrays ( print_r
), they are identical. I don't know much about objects in PHP, but could the array_push
-function make the $visit_arr
-array less valid for this procedure? Or is the problem elsewhere? thank.
// create array
$visit_arr = array();
// loop through visit items from form
$i = 0;
while ( $i < $num_visit_items ) {
$j = $i + 1;
if ( isset( $_POST['visit'.$j.''] ) ) {
array_push($visit_arr, $_POST['visit'.$j.'']);
}
$i++;
}
// alternative array (which works)
$visit_array_with_manual_values = array(123,456,789);
// create item in Podio
$fields = new PodioItemFieldCollection(array(
new PodioTextItemField(array(
"external_id" => "titel",
"values" => $firstname
)),
new PodioTextItemField(array(
"external_id" => "lastname",
"values" => $lastname
)),
new PodioAppItemField(array(
"external_id" => "visit",
"values" => $visit_arr
)),
new PodioTextItemField(array(
"external_id" => "description",
"values" => $description
))
));
source to share
No one has answered this question yet
See similar questions:
or similar: