I'm using Podio's podio-php for their API for saving data from a form to Podio, and haven't had any issues except this small but annoying one. When I use the $visit_arr
-array, the fields in Podio are blank, but when I use the manually 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 can the array_push
-function somehow make the $visit_arr
-array less valid for this procedure? Or is the problem somewhere else? Thx.
// 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
))
));