Created
November 19, 2018 05:49
-
-
Save ep4sh/ece32f49380dd46b6ce53297aaaca7e6 to your computer and use it in GitHub Desktop.
#2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// name, damage, durability | |
$weaponSet1 = [ | |
["Sword", 15, 80], | |
["Scythe", 35, 10], | |
["Club", 5, 40], | |
]; | |
$json = json_encode($weaponSet1); | |
file_put_contents("output.json", $json); | |
echo "RANDOM = ".$random = random_int(0,1)."<br>"; | |
if ($random != 0) { | |
$ranndomChoise = random_int(0,2); | |
$weaponSet2 = [ | |
["Immortal King blade", 700, 100], | |
["Nova", 1400, 0], | |
["Death Touch", 5000, 0], | |
]; | |
array_push($weaponSet1, $weaponSet2[$ranndomChoise]); | |
$json = json_encode($weaponSet1); | |
file_put_contents("output2.json", $json); | |
} | |
if (file_exists("output2.json")) { | |
$str1 = file_get_contents("output.json"); | |
$str2 = file_get_contents("output2.json"); | |
$arr1 = json_decode($str1); | |
$arr2 = json_decode($str2); | |
var_dump($arr1); | |
echo "<br>"; | |
echo "<br>"; | |
var_dump($arr2); | |
echo "<br>"; | |
echo "<br>"; | |
echo "<br>"; | |
$df = array_diff($arr1,$arr2); | |
print_r($df); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment