Jump to content

For not working...


EsOne

Recommended Posts

I have a script that decodes a json file for information, and I am trying to do a for script for information, but I keep getting an error.

 

I am trying to use the following script

 

<?php

$gameCap=0;
$glowCt=0;
$fishCt=0;

for($i in $hay[2][2]{
if($hay[2][2]{i}{'in_env'}==1){
$fishCt++; }
if($hay[2][2]{i}{'game_specifics'}){
$gameCap+$hay[2][2]{i}{'game_specifics'}{'rewards'}{0}{'cap'};
$glowCt++;
} 
}
?>

 

And i get:

 

 

Parse error: syntax error, unexpected T_STRING, expecting ';'

Link to comment
Share on other sites

Thanks for the reply.

 

I think I am starting to understand. However, i is actually part of the array (As far as I can understand)

 

I'm actually trying to convert some javascript into PHP.

 

Here is the js:

 

 var gameCap=0;
var glowCt=0;
var fishCt=0;

for(var i in json[2][2]){
if(json[2][2][i]['in_env']==1){
fishCt++;
if(json[2][2][i]['game_specifics']){
gameCap+=Number(json[2][2][i]['game_specifics']['rewards'][0]['cap']);
glowCt++;
}
}
} 

 

I'm trying to basically do for each i part of the array, if "in env" is found in the i section ++ to fishCT

also if there is a "game specifics" array section to add $gameCap to what is in the "cap" part of the array.

 

Sorry if I sound dumb in the way I explain. I am quite new to PHP

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.