Hi guys, I’m having some problem with my PHP code, I’ve been having this problem for the past two days and have a deadline to meet (tomorrow) so I’m really trying to fix this ASAP. I’m trying to get a JSON file to be loaded then decoded, then I need to go through the array that’s built (which is what I’m using the while loop for) then I need to check if a field is a certain value (what I’m using the if statement for). My code is below. Any help is appreciated:
[php] <?
$proj = json_decode(file_get_contents(‘data/new.json’));
$projdata = get_object_vars($proj);
$count = count($proj);
//print_r($proj);
$musthaves = array();
$strategics = array();
$products = array();
$musthaveproj = array();
for($i=0; $i <= $count; $i++) {
$filter = $projdata[$i];
$if = ($filter[‘type’] == ‘Must-Have’ ? array_push($musthaves, $filter));
// if($filter[‘type’] == ‘Strategic’) array_push($strategics, $projdata);
// if($filter[‘type’] == ‘Product’) array_push($products, $projdata);
}
//print_r($musthaveproj);
$count1 = count($musthaves);$count2 = count($strategics);$count3 = count($products);
//echo ($count1);echo ($count2);echo ($count3);
print_r($musthaves);
//print_r($projdata[0]['devcapacity']);
echo ("
<script type='javascript/text'>
(function(){
var graphDefinition = {
categories : ['test1', 'test2', 'test3'],
dataset: {"."'test1':[{".$musthaveproj[0]['id'])."
}
var chartObject = uv.chart('StackedBar', graphDefinition, optionalConfiguration)
});
</script>";?>[/php]