jcbarr Posted March 20, 2007 Share Posted March 20, 2007 I have this array http://cbl-baseball.com/stats.php named $cleanPstats Here is the code that I used to generate it; <?php $stats = file("all_stat.htm"); foreach ($stats as $line){ $line = strip_tags($line); if (trim($line) != "") $newStats[] = $line; } //echo "<pre>"; //print_r($newStats); //echo "</pre>"; foreach ($newStats as $player){ $pstats = explode(" ", $player); foreach ($pstats as $line){ if (trim($line) != "") $cleanPstats[] = trim($line); } } echo "<pre>"; print_r($cleanPstats); echo "</pre>"; ?> Now here comes the tricky part...this might be too much to ask but I'll ask anyway, and if no one has the time for thats okay. That array is huge. It contains season and career stats for each player on every team. The team is listed first, then the season batting, season pitching and then the career batting and career pitching for each player. What I'm looking to do is to somehow figure a way to enter this information in to a database by executing this script while keeping the association between the player and the team and also differentiating season stats from career stats. I would of course have two tables, one for season stats and one for career, or even 4 to separate pitching from batting as well. The problem is that I have no idea how to go about this. There is a lot of useless information in that array that can be taken out. Such as stat names, overall team statistics. I'm only interesting in the 19 batting stats (excluding the 20th and or 21st) and the pitching stats for each player. Any ideas on how to go about this? Link to comment https://forums.phpfreaks.com/topic/43574-more-array-questions/ Share on other sites More sharing options...
jcbarr Posted March 20, 2007 Author Share Posted March 20, 2007 Could an admin possibly move this to the freelance forum? Thanks Link to comment https://forums.phpfreaks.com/topic/43574-more-array-questions/#findComment-211644 Share on other sites More sharing options...
Barand Posted March 21, 2007 Share Posted March 21, 2007 You'd be better using delimited text files eg Pos, FName, LName, Avg, G, AB, R, H, 2B, 3B, HR, RBI, BB, SO, RC, OBP, Slg, SB, CS GDP, LHP, RHP, E, Pct LF, Rothschild, Barney, 0.281, 162, 690, 91, 194, 63, 3, 20, 57, 38, 119, 102, 0.318, 0.468, 35, 15, 15, 0.288, 0.279, 0 1.000 1B, Bird, Kurt, 0.335, 162, 644, 78, 216, 17, 0, 19, 90, 48, 68, 110, 0.379, 0.45, 10, 12, 25, 0.339, 0.334, 0 1.000 RF, Duncan, Skip, 0.305, 162, 623, 53, 190, 14, 0, 24, 72, 34, 111, 94, 0.339, 0.443, 2, 4, 41, 0.303, 0.306, 0 and loading those into your database tables See mysql's LOAD DATA INFILE command Link to comment https://forums.phpfreaks.com/topic/43574-more-array-questions/#findComment-211677 Share on other sites More sharing options...
jcbarr Posted March 21, 2007 Author Share Posted March 21, 2007 Hmm...good suggestion, but the output is HTML from the game itself and I can't change that, unless there is some way to convert it...I'll look in to it. Thanks for the suggestion. Link to comment https://forums.phpfreaks.com/topic/43574-more-array-questions/#findComment-211719 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.