i Have a array which is of variable size. Suppose currently the array $type have two elements as:
Array ( [19] => create [20] => code )
the script i use is of like this:
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Weak Area'],
[('<?php echo $type[0]; ?>'), 5],
[('<?php echo $type[1]; ?>'), 4]
]);
and works fine, but since the array elements may change i tried changing the script as :
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Weak Area'],
[('<?php echo $type[0]; ?>'), 5],
[('<?php echo $type[1]; ?>'), 7],
[('<?php echo $type[2]; ?>'), 34],
[('<?php echo $type[3]; ?>'), 12],
[('<?php echo $type[4]; ?>'), 40],
[('<?php echo $type[5]; ?>'), 35]
]);
but it does not show the output if array index are out of bound. what i wanted to do is something like if type[4] is not present it will just by pass it and show output of upto type[3], can someone please help me out.