Jump to content

devWhiz

Members
  • Posts

    266
  • Joined

  • Last visited

Everything posted by devWhiz

  1. $ratios[$id] = sprintf("%.16f", $value1 / $value2); that is what calculates the ratio, so I would have to place $ratios[$id] = sprintf("%.16f", $value1 / $value2); after the if statement to recalculate the ratio?
  2. $x!=-1 is an infinite loop.. its just a little project I am working on
  3. Here is the script <?php $array[0]['id'] = 0; $array[0]['value1'] = 1000; $array[0]['value2'] = 15000; $array[0]['value3'] = 15000; $array[0]['value4'] = 0; $array[1]['id'] = 1; $array[1]['value1'] = 500; $array[1]['value2'] = 3300; $array[1]['value3'] = 3300; $array[1]['value4'] = 0; $array[2]['id'] = 2; $array[2]['value1'] = 250; $array[2]['value2'] = 3500; $array[2]['value3'] = 3500; $array[2]['value4'] = 0; $array[3]['id'] = 3; $array[3]['value1'] = 800; $array[3]['value2'] = 2500; $array[3]['value3'] = 2500; $array[3]['value4'] = 0; for($x=0; $x!=-1; $x++){ $random = rand(0,3); foreach($array as $arrays){ $id = $arrays['id']; $value1 = $arrays['value1']; $value2 = $arrays['value2']; $value3 = $arrays['value3']; $value4 = $arrays['value4']; $newarray[$id]['value1'] = $value1; // income $newarray[$id]['value2'] = $value2; // cost $newarray[$id]['value3'] = $value3; // static.. init cost $newarray[$id]['value4'] = $value4; // owned $ratios[$id] = sprintf("%.16f", $value1 / $value2); print_r($ratios); } $bestratio = max($ratios); $idforbestratio = array_search($bestratio, $ratios); $array[$idforbestratio]['value2'] += $array[$idforbestratio]['value3']; if($array[$idforbestratio]['value4'] < 10){ $array[$idforbestratio]['value2'] -= $array[$idforbestratio]['value3']; } echo $array[$idforbestratio]['value2']."\n"; $array[$idforbestratio]['value4'] += 10; sleep(1); } the script calculates the best ratio for each array entry ratios are as follows Array ( [0] => 0.0666666666666667 [1] => 0.1515151515151515 [2] => 0.0714285714285714 [3] => 0.3200000000000000 ) since $array[3] has the highest ratio, execute $array[$idforbestratio]['value2'] += $array[$idforbestratio]['value3']; so now $array[3]['value2'] would equal 5000 but I put the if statement in to change the value2 back to 2500 if value4 is under 10, it changes the value but the ratio doesnt update.. I dont get what I am doing wrong or what I would have to do to get the ratio to update.. ive tried to make the array value super global but it still refuses to update the ratio the next loop any ideas on what I could do to get this to update the ratio value?
  4. The data is in an XML File but.. the script is going to be doing math, adding the variables and such so I figured it was better to make all of the values as a variable so I would be able to update them, as I wouldnt want php to try and ended the value in the XML file itself, I hope that makes sense Thanks -CLUEL3SS
  5. well what I was going to do is store all of the data as variables like this $ID45 = 45; $ID45Cost1 = 12000; $ID45Cost2 = 150; $ID40 = 40; $ID40Cost1 = 20000; $ID40Cost2 = 500; $ID55 = 55; $ID55Cost1 = 5000; $ID55Cost2 = 300; I figured it would be easier and faster to put all the information into an array and then call it like $array[iD]['Cost1'], $array[iD]['Cost2'], etc What do you think? any suggestions? Thanks
  6. so I have info like this.. ID = 40 Cost1 = 20000 Cost2 = 500 ID = 45 Cost1 = 12000 Cost2 = 150 ID = 55 Cost1 = 5000 Cost2 = 300 How can I get this info in an array where I could get the data like this $array[40]['Cost1'] would equal 20000 $array[55]['Cost2'] would equal 300 or if I used print_r($array) it would output Array ( [40] => array ( [iD] => 40 [Cost1] => 20000 [Cost2] => 500 ) [45] => array ( [iD] => 45 [Cost1] => 12000 [Cost2] => 150 ) [55] => array ( [iD] => 55 [Cost1] => 20000 [Cost2] => 500 ) ) or something like that etc etc This is probably easy for most, any help with this is greatly appreciated, thanks
  7. ty guys again for the responses, I ended up just taking a shortcut, just thought it would be cool to use true, false etc as it seemed to look nicer but this way works as well, thanks
  8. im really exhausted, been working on moving to a new house, I will try to explain further in better detail if you guys dont get what I am saying, I can't think straight right now, yet I still insist of trying to add features to a script of mine, ;P thank you guys for the responses as well, always appreciated
  9. basically.. I am reading an xml file that is as follows <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> I use simplexml to parse the xml file and put the objects in an array, well.. you see how there is an ID assigned for each <land> well what I want to do is use $include_a = true; $include_b = false; $include_c = true; if true it puts certain ids in an array, and then I will use if(in_array()) to check to see if the id is in the array, if it is, it skips the calculation, basically the script is just reading the xml file, dividing the income by the cost to get a certain ratio, well the script wont block out any ids if I dont set it to true or false on whether or not to include the id in the array, I know i could probably use if statements to check and see if the variables are true or false, if true it updates the array with the id and then I use in_array to search, if the id is in the array it will continue; I know I could do this to make it easier on myself if(!in_array($ID, $IDarray)) { calculate ratios } continue;
  10. How would I go about doing this... I want to have a few variables equaling either true or false... if true, it puts 'x' number into array I dont know how to add more than one 'x' number into the array like this $include_a = true; $include_b = false; $include_c = true; if include_a is true, add 24 to the array, include_b is false so dont add 5 to the array, include_c is true so add 13 to the array... $include_a = true; // if true, add 24 to the array $include_b = false; // if true, add 5 to the array $include_c = true; // if true, add 13 to the array if($include_a == true || $include_b == true || $include_c == true) { $array = array(24, 5, 13); } now since include_b is false, it should only add 24 and 13 to the array.. do I use else if? or many if statements or what? this is probably going to confuse everyone, its kind of hard to explain
  11. yeah I would use file_get_contents() like so $string = file_get_contents("www.example.com"); echo $string; I'm not familiar with dom so I would just use explode to extract certain content... bad habit there though
  12. Ive set the time limit up and it still isnt working for me, ignace, how would I use your suggestion? Thanks for the responses
  13. <?php $orig = file('list.txt'); $new = array(); $new[] = 'dmy'; $slice_size = 8000000; for($i=0;$i<count($orig);$i += $slice_size) { $new[] = array_slice($orig,$i,$slice_size); } for ($i=1;$i<count($new);++$i) { file_put_contents('WordList ['.$i.'].txt',implode('',$new[$i])); } ?> I have text files and wordlists that have up to 250 million lines, I need this script to split the main file which is upwards to 800 MB, and split it into any size I specify, this script works for smaller files but It wont even split a file that is 6 million lines, ~58 mb any help with this is appreciated
  14. http://www.sumob.com/watch/ implemented nicely
  15. thats how I worked with php, I started reading other peoples scripts and now I can write my own script with little help, are their any good sites that you can recommend I take a look at to start getting the grasp of css, and html as well? Thanks for the responses BTW
  16. I was curious as to what I could use to make a center peice? I got <br><br><br><br><br><br><br><br><br><br> <div id="left-menu" style="background-color:#181818;height:800px;width:160px;float:left;"> </div> <div id="right-menu" style="background-color:#181818;height:800px;width:160px;float:right;"> </div> float:center doesnt seem to work, Im a noob to all of this, just trying to work on my web design skills
  17. lol sorry, Im out of the HTML loop, this was my first attempt at trying to make a template for my website, I looked around and found t hat premade template, with no prior knowledge of how anything works, but I look at the code cssfreakie had in his blog and its put me in the right direction to create a better template, thanks
  18. /sarcasm
  19. lolol.. umad? I don't see what the problem is... I only stated that I did not create the template, after your reply... Assumed I put the template together myself...
  20. ... what are you talking about? I didnt make the template.... thanks for the links I will check them out
  21. this is something similar to what I am looking for
  22. I wanted to bring the side columns all the way to the side, the left column bordering the browser, ame with the right column, then expand the width of the center area, also widen the header at the top, and have a navigation bar under it, here is the template http://bom-mob.com/clueless/ <html> <head> <title>[Your site name goes here]</title> </head> <STYLE> a:link { color : #C1C4C6; text-decoration : none; } a:visited { color : #C1C4C6; text-decoration : none; } a:active { color : #C1C4C6; text-decoration : none; } a:hover { color :#666666; text-decoration : none; } </STYLE> <body background="images/bg.gif"> <div align="center"> <center> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" id="AutoNumber1"> <tr> <td><img border="0" src="images/header.gif" width="800" height="101"></td> </tr> </table> </center> </div> <div align="center"> <center> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="800" id="AutoNumber2" height="10"> <tr> <td height="1"></td> <td height="1"></td> <td height="1"></td> </tr> </table> </center> </div> <div align="center"> <center> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="800" id="AutoNumber3" height="522"> <tr> <td width="144" valign="top" height="522"> <img border="0" src="images/navigation.gif" width="150" height="14"><br> <table border="1" cellpadding="2" cellspacing="2" style="border-collapse: collapse" bordercolor="#181818" width="150" id="AutoNumber4" height="9"> <tr> <td width="100%" bgcolor="3D3D3D" height="9" valign="top"> <p align="left"><font face="Verdana" size="1" color="#C1C4C6"> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="105%" id="AutoNumber5" height="1"> <tr> <td width="100%" height="1" > <img border="0" src="images/footer.gif" width="150" height="14"><br> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="104%" id="AutoNumber6"> <tr> <td width="100%"> <img border="0" src="images/poll.gif" width="150" height="14"></td> </tr> </table> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="104%" id="AutoNumber7"> <tr> <td width="100%" bgcolor="3D3D3D" valign="top"><font color="#FFFFFF"> <font face="Verdana" size="1"> <br><br><br><br><br><br><br> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="104%" id="AutoNumber8"> <tr> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="104%" id="AutoNumber9"> <tr> </tr> </table> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="104%" id="AutoNumber10"> <tr> <td width="100%" bgcolor="3D3D3D" valign="top"> <table border="0" cellpadding="3" cellspacing="3" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber15"> <tr> <br><br><br><br><br><br><br> </tr> </table> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="104%" id="AutoNumber11"> <tr> <td width="100%"> <img border="0" src="images/footer.gif" width="150" height="14"><br> </td> </tr> </table> </td> <td width="506" valign="top" height="522"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="450" id="AutoNumber12" align="center"> <tr> <td align="center"> <img border="0" src="images/content-large.gif" width="450" height="14"></td> </tr> </table> <table border="1" cellpadding="2" cellspacing="2" style="border-collapse: collapse" bordercolor="#181818" width="450" id="AutoNumber13" align="center"> <tr> <td bgcolor="3D3D3D" valign="top"> <font color="#FFFFFF" size="1" face="Verdana"> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="450" id="AutoNumber14" align="center"> <tr> <td> <img border="0" src="images/footer-large.gif" width="450" height="14"></td> </tr> </table> <p align="center"><br> </td> <td width="150" valign="top" height="522"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber16"> <tr> <td width="100%"> <img border="0" src="images/news.gif" width="150" height="14"></td> </tr> </table> <table border="1" cellpadding="2" cellspacing="2" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber17"> <tr> <td width="100%" bgcolor="3D3D3D"> <font size="1" face="Verdana" color="#FFFFFF"> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber18"> <tr> <td width="100%"> <img border="0" src="images/footer.gif" width="150" height="14"><br> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber19"> <tr> <td width="100%"> <img border="0" src="images/stats.gif" width="150" height="14"></td> </tr> </table> <table border="1" cellpadding="2" cellspacing="2" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber20"> <tr> <td width="100%" bgcolor="3D3D3D" valign="top"> <font face="Verdana" size="1" color="#FFFFFF"> </br> </br> </br> </br> </br> </br> </br> </br> </br> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber21"> <tr> <td width="100%"> <img border="0" src="images/footer.gif" width="150" height="14"><br> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber22"> <tr> <td width="100%"> <img border="0" src="images/featured.gif" width="150" height="14"></td> </tr> </table> <table border="1" cellpadding="2" cellspacing="2" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber23"> <tr> <td width="100%" bgcolor="3D3D3D"><font face="Verdana" size="1" color="#FFFFFF"> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#181818" width="100%" id="AutoNumber24"> <tr> <td width="100%"> <img border="0" src="images/footer.gif" width="150" height="14"></td> </tr> </table> </td> </tr> </table> </center> </div> <div align="center"> <center> <table border="1" cellpadding="2" cellspacing="2" style="border-collapse: collapse" bordercolor="#181818" width="800" id="AutoNumber25"> <tr> <td bgcolor="3D3D3D"> <p align="center"><font color="#FFFFFF" face="Verdana" size="1">Content Copyright 2005 [your site]. Layout created by </font><font face="Verdana"> <a href="http://www.zymic.com"><font size="1">www.zymic.com</font></a><font size="1"> </font></font></td> </tr> </table> </center> </div> </body> </html> any help is appreciated, thanks!
  23. so like, if I set up to where I could have users sign up on my site and such the information they use to sgn up with me stored in a mysql DB, and when someone like loads their profile it calls to the database>=? would I be able to write the code to have users register on my site? Im new to the whole website thing, I just usually create scripts to run in CLI
  24. I can write php and such just fine, I just opened up a new site and was curious as to what I could use mysql databases for? Thanks
  25. Yeah I caught that after awhile, my mistake $myurl = "http://mydomain.com/abc/moretext.html" if(stristr($myurl, '/abc/') || stristr($myurl, '/efg/') || stristr($myurl, '/xyz/')) { code to execute... }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.