/    Sign up×
Community /Pin to ProfileBookmark

Whats wrong with this code?

[code=php]$party[0] = “1”;
$party[1] = “2”;
$party[2] = “2”;
$party[3] = “3”;

$all[0] = “10”;
$all[1] = “11”;
$all[2] = “12”;
$all[3] = “13”;
$all[4] = “14”;
$all[5] = “15”;

foreach ($party as $value) { echo $value; };
echo ‘<br>’;
foreach ($all as $value) { echo $value; };

function depositPokemon($partyArray, $allArray, $inPartyIndex) {
$toAddInAll = count($allArray);
$allArray[$toAddInAll] = $partyArray[$inPartyIndex];

for ($i = $inPartyIndex; $i<count($partyArray)-1; $i++) {
$lastNull = count($partyArray)-1;
$partyArray[$i] = $partyArray[$i+1];
$partyArray[$lastNull] = null;
};

$returnArray[“PARTY”] = $partyArray;
$returnArray[“ALL”] = $allArray;
return $returnArray;
};

function withdrawPokemon($partyArray, $allArray, $inAllIndex) {
$toAddInParty = count($partyArray);
$partyArray[$toAddInParty] = $allArray[$inAllIndex];

for ($i = $inAllIndex; $i<count($allArray)=1; $i++) {
$lastNull = count($allArray) – 1;
$allArray[$i] = $allArray[$i+1];
$allArray[$lastNull] = null;
};

$returnArray[“PARTY”] = $partyArray;
$returnArray[“ALL”] = $allArray;
return $returnArray;
};

$updater_dep_pok_p = depositPokemon($party, $all, 3);
$party = $updater_dep_pok[“PARTY”];
$all = $updater_dep_pok[“ALL”];

$updater_with_pok_p = depositPokemon($party, $all, 3);
$party = $updater_with_pok[“PARTY”];
$all = $updater_with_pok[“ALL”];

echo ‘<br>’;
foreach ($party as $value) { echo $value; };
echo ‘<br>’;
foreach ($all as $value) { echo $value; };

[/code]

ERROR
Fatal error: Can’t use function return value in write context on line 37.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @deepode spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...