php - checking json array with my value to do operation otherwise other operation -
consider have json array this
["map14","map20","map21","map22","map23","map24","map25","map31","map32","map33","map34","map35","map36","map37","map40","map41","map42","map46","map49","map50"]
with json array need check if passed value exists need operation or otherwise other operation....
javascript code:
function pop(e,id) { $.getjson( 'layoutcheck.php', { some_get_var: 1 }, function(output){ var i=0, total = output.length; ( = 0; < total; ++i ) { if(isarray(output[i]==id)) { // soome stuff if value exists in database } else{ // if not exists other operation } } }); } </script>
layoutcheck.php fetch information database , create json array..
but code fails display output.. please rectify me ..
thanks
isarray()
won't check if object in array, if object array.
this means output[i]==id
(which either true
or false
) checked. not arrays; meaning you'll go else
part of condition.
you can try using like:
if(output.indexof(id) != -1) { // soome stuff if value exists in database } else{ // if not exists other operation }
instead of for
loop.
Comments
Post a Comment