I'm having an issue where I'm trying to subtract 1 from a number. This number is stored in an array. The array is formed by reading a line from a text file, splitting it by "|" and then storing it into an array.
The text file looks like this: 100|2
Here's my code:
function remove1($key, $privorno=0) {
$actualFile = file_get_contents("users/" . $key . ".txt");
$numtoremove = explode('|', $actualFile);
if($privorno == 1) {
file_put_contents("users/" . $key . ".txt", $numtoremove[0] . "|" . $numtoremove[1] - 1);
} else {
file_put_contents("users/" . $key . ".txt", $numtoremove[0] - 1 . "|" . $numtoremove[1]);
}
When this executes it leaves the text file as just "100" (I.E Deleting the 2 and the "|")
Any help would be great. Thanks!