Created
February 26, 2015 15:17
-
-
Save backy22/9ca60eeeb8e840c65514 to your computer and use it in GitHub Desktop.
This file contains 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 | |
$dataFile = 'ss.dat'; | |
$cleandate = $_GET['cleandate']; | |
$userhouse = $_GET['userhouse']; | |
$userid = $_GET['userid']; | |
$fp = fopen($dataFile, "r"); | |
while (($dataRow = fgetcsv($fp, 0, ",")) !== FALSE) { | |
$dataArray[] = $dataRow; | |
} | |
fclose($fp); | |
$rightData = array(); | |
foreach ($dataArray as $eachData){ | |
// dataArray:[0]2015-2-15 [1]根津 [2]太田 [3]400 [4]0みたいな各配列 | |
// eachData[0]:ex 2015-02-15 | |
// eachData[1]:ex 根津 | |
// eachData[2]:ex 太田 | |
// eachData[3]:コインランドリー代 | |
// eachData[4]:立替費用 | |
if( | |
$eachData[0] == $cleandate && | |
$eachData[1] == $userhouse && | |
$eachData[2] == $userid | |
){$rightData = $eachData; | |
} | |
} | |
if( | |
$rightData[3] == null or | |
$rightData[4] == null){ | |
$rightData[3] = ""; | |
$rightData[4] = ""; | |
} | |
$response = array( | |
'cleandate' => $cleandate, | |
'coinlaundry' => $rightData[3], | |
'cost' => $rightData[4] | |
); | |
echo json_encode($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment