I am trying to limit the output of the combo box, so it does not add the options with the $id that matches the numbers in the array $nid. This is through the harvest (time tracking) API, although the main question is can you use in_array to compare two arrays or do you need to use another command?
<?php
if(file_exists('HarvestAPI.php')){
require_once('HarvestAPI.php');
} else {
echo 'Cannot load HarvestAPI.php';
}
/* Register Auto Loader */
spl_autoload_register(array('HarvestAPI', 'autoload'));
$api = new HarvestAPI();
$api->setUser('email@address.com');
$api->setPassword('password');
$api->setAccount('account');
$api->setSSL(true);
$nid= array('604695', '604697', '604696', '604698');
?>
<html>
<form action="testvar.php" method="post">
<body>
<?
$result = $api->getTasks();
if( $result->isSuccess() ) {
#print_r($result->data); exit();
echo '<select name="task" id="tid">';
foreach($result->data as $tasks) {
unset($id,$name);
$id = $tasks->get("id");
$name = $tasks->get("name");
if(in_array($nid, $id)){
echo '<option value="'.$id.'">'.$name.'</option>';
}
}
echo '</select>';
echo '<input type="submit" value="Submit" />';
}
?>
</body>
</form>
</html>
Thank you!
Aaron