-
Posts
266 -
Joined
-
Last visited
Everything posted by devWhiz
-
what about this for($abc=1; $abc<25; $abc++) { $ABC1 = rand($abc); $ABC1 = $ABC2; echo $ABC1 . " " . $ABC2."\n"; } when I want to randomize abc1 but I want it to make abc2 randomized also but not different than abc1
-
Yeah I was looking at shuffle, didnt know if there was a better way or something, this will work for now, thank you!
-
I dont know how to word this really. what I want to do is $Var[] = 3; $Var[] = 6; $Var[] = 2; $Var[] = 17; for($i=0; $i!=count($Var); $i++) { echo "#$i: ".$Var[$i]."\n"; } I know I might be able to use rand() but I need it to echo ALL of the variables in the array in a random order, I know if I use count to find out how many variables there are that it would echo them 4 times randomly but might echo the same variable 2 times making it to where it only echos 3 different varables, if I am being confusing please let me know, I just want to get this resolved, thanks!
-
what would be the best code to use to just use curl to reload a url in a loop? Like what all options do I need that would be the fastest? Ive been using <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.example.com'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_close($ch); ?>
-
file_get_contents or Curl - which one to take for a little parser
devWhiz replied to dilbertone's topic in PHP Coding Help
as file_get_contents() takes less code and is quicker to write for many, I prefer curl as when I write scripts, a big factor is how fast I can get it to grab data from a header, like my scripts are optimized for servers and I mainly write the scripts to automate actions on myspace and facebook applications, but all of my scripts need to load a header fast, grab data, parse it, throw the data I need into variables and then I manipulate new headers and send the information to the server, Im just rambling, my bad I don't know anything about preg_match yet, I think I might try to learn that soon -
or make a function out of the function call it inside another function?
-
ok that works but it shortens up the decimal and rounds it, is there a way to have it calculate the decimal without rounding it? like 0.00092144444443 rounds to 0.000920 how can I get it to keep it at 0.00092144444443
-
Deprecated: Function split() is deprecated in path\htdocs\
devWhiz replied to rabbani's topic in PHP Coding Help
http://php.net/manual/en/function.explode.php -
<?php $a = 350000; $b = 3600000000; echo $hmm = $a / $b; outputs 9.7222222221617E-5 while <?php $a = 350000; $b = 360000000; echo $hmm = $a / $b; outputs 0.000972222222 its only one digit shorter, how can I get the first code to produce the same results, Ive tried using float, int maxes out and Ive changed my floating point in php.ini, no luck
-
$GLOBALS[] was the fix, Thank you!
-
<?php $a = array(3, 4, 18, 15); $b = array(12, 10, 11, 24); $c = array(5, 6); $d = array(7, 8, 13); $e = array(19, 16); function test($ID) { if(in_array($ID, $a)) { echo "a"; } if(in_array($ID, $b)) { echo "b"; } if(in_array($ID, $c)) { echo "c"; } if(in_array($ID, $d)) { echo "d"; } if(in_array($ID, $e)) { echo "e"; } } $test = 3; test($test); ?> Why doesn't that echo "a" I don't really get what I am doing wrong, any help is appreciated
-
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
Sweet, I will work at that, ok ONE last thing and Ill stop buggin you, how would ignore a few ids? Like say I didnt want it to calculate the ratio for 22 or, 10, or 6, just examples but what could I use to block those out, and when I get paid I will throw you a few dollars on paypal if you want for helping me out -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
Man, Youre awesome bro! I really appreciate the help! One more thing What would I have to do to, get the script to output all of the ratios in order like... Buy $Name first ::: RATIO : $ratio ::: Buy $Name second ::: RATIO : $ratio ::: Buy $Name third ::: RATIO : $ratio ::: Buy $Name fourth ::: RATIO : $ratio ::: Buy $Name fifth ::: RATIO : $ratio ::: Buy $Name sixth ::: RATIO : $ratio ::: I don't expect you to help me with that, If you could maybe point me in the right direction, You've already went out of your way to help me with what you have so far, thanks! -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
<outer> <xml> <establishments> <land> <id>24</id> <cost>920000000000</cost> <income>$100,000,000</income> <name>NAME</name> </land> <land> <id>17</id> <cost>921000</cost> <income>$100</income> <name>NAME</name> </land> <land> <id>3</id> <cost>2763000</cost> <income>$300</income> <name>NAME</name> </land> </establishments> </xml> </outer> way more entries than that though, 20+, I just cut it down some, and I was wrong, name is in the XML -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
Doesnt seem like the arrays are holding any data.. <?php $XML = simplexml_load_file("get_city_list.xml"); $ratios = array(); $properties = array(); foreach($XML->xml->establishments->land as $value) { $key = $value->id; $properties[$key]['cost'] = $value->cost; $remove = str_replace('$', '', $value->income); $income = str_replace(',', $remove); $properties[$key]['income'] = $income; $ratios[$key] = $income / $value->cost; } $highestRatio = max($ratios); // get the highest ratio $propertyKey = array_search($highestRatio, $ratios); // get the properties ID $property = $properties[$propertyKey]; // get the property with the highest ratio echo $property['name'] . ' has the best ratio of ' . $highestRatio; sleep(10000); ?> var_dump() and print_r() both show that there is no data in the ratios array if I echo out $key."\n" it prints the IDs of the property in the XML file just fine.. I'm not real sure where something went wrong, and there is no ['name'] value in the xml but that shouldnt have caused any issues -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
ahh seen you edited it, about to check it out ty, I was having a few problems with the other code Just figured I kind of messed something up -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
ok, I think Im gonna have to modify the code a little bit, Im gonna work on it and let you know how it turns out, and if I need anymore help, ty for takin to time ot put that code together for me -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
all of the properties within the xml file I just listed 3 to shorten it up a bit, I need it to load the file, calculate the best ratio, buy the property, reload the file to check for the best ratio among properties again and repeat Thanks for helpin me wildteen -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
<?php $XML = simplexml_load_string("property_list.xml"); foreach($XML->xml as $value) { if($value->id == 10) { $id10_cost=$value->cost; $id10_income=$value->income; $id10_ratio = $id10_income / $id10_cost; } else if($value->id == 12) { $id12_cost=$value->cost; $id12_income=$value->income; $id12_ratio = $id12_income / $id12_cost; } else if ($value->id == 16) { $id16_cost=$value->cost; $id16_income=$value->income; $id16_ratio = $id16_income / $id16_cost; } } ?> Thats shortened, but thats my code to parse out and get the ratios, I could use max() to find the highest ratio but I don't know how I could define the highest ratio in a variable and then match it up with the ratios to see what property ID it would be that I would have to purchase the property. sorry if I am being confusing -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
Hmm, Ok how about this, I guess I should have explained a little but more my bad Im tryin to game a calculator for this game to buy the best bang for buck property (lol), as lame as it sounds, I make money making tools for this game so w/e So there is property in the game, I use simplexml to parse out the cost and income and then I calculate the ratios, well I want to be able to buy the property that has the best ratio, I just need to figure out how to define the best ratio and then have the script know what property it is that has the best ratio, and then buy the property, a url buys the property so I would use file_get_contents -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
Well I will have 20+ ratios I need to sort, I need to be able to calculate all of the ratios and then echo the highest one.. IE; Ratio 1 = 0.00023 Ratio 2 = 0.00025 Ratio 3 = 0.00043 Ratio 3 is the highest so I will need to put that into a variable and then echo it out -
sort decimals least to greatest and vice versa?
devWhiz replied to devWhiz's topic in PHP Coding Help
Im going to PM you wildteen -
Ok so say I have php do some calculations for me $Value1 = 300; $Value2 = 100000; $FirstRatio = $Value1 / $Value2; $Value3 = 8000; $Value4 = 6000000; $SecondRatio = $Value3 / $Value4; $FirstRatio = 0.003 $SecondRatio = 0.0013 How would I go about doing these calculations and then sorting $FirstRatio and $SecondRatio and then it would take the highest ratio ($FirstRatio) and it would echo the value?
-
the xml I am dealing with has multiple "entry"s here is the code <xml> <entry> <target_user> <user_id>467180156</user_id> <mob_name>Insuccesso%20your%2C%20Level%201000</mob_name> </target_user> <paid_user> <user_id>533455151</user_id> <mob_name>DONT%20DO%20IT30</mob_name> </paid_user> <amount>12001680000</amount> <is_npc>false</is_npc> <placed_time_ago>3 hours ago</placed_time_ago> <level>1000</level> <location_name>New York City</location_name> </entry> <entry> <target_user> <user_id>288050627</user_id> <mob_name>LITTLE%20PRIME%20TIME%2C%20Level%20993</mob_name> </target_user> <paid_user> <user_id>446419622</user_id> <mob_name>KG%20THE%20BODACIOUS</mob_name> </paid_user> <amount>14328480000</amount> <is_npc>false</is_npc> <placed_time_ago>3 hours ago</placed_time_ago> <level>993</level> <location_name>New York City</location_name> </entry> </xml> I need to put target_user->user_id into a loop and the same for paid_user->user_id etc The code in the first post it only prints the first letter and it confusing me, any help is appreciated