Jump to content

dsbpac

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by dsbpac

  1. Can someone please help me!! How can I get the value in an link like <a href="#first">Link</a> I need to get first in an variable. I have search an search but I can't find any help. I know I can get it if i pass it in the URL name but the way the css is coded. I need to get the value like it is. Thank you.
  2. I have an array that has salary, position, and projected. $arr[] = array('salary' => $row["salary"], 'position' => $row["position"], 'projected' => $row["projected"]) Position = QB, RB, WR, TE, PK, DEF Salary = 7000, 8300, 5000 Projection = 10, 20, 30 I need help wrapping my head around how to do the following. I want the script to give me the most possible projected points based on a total salary number and limited to specific amount of players in each position. QB -1 RB - 2 WR - 3 TE - 1 PK - 1 DEF - 1 Max salary of 60k. Any help is greatly appreciated.
  3. I changed array1 to be more structured now. [0] => Array1 ( [0] => 32347 [1] => 22188 [2] => 37493 [3] => 37056) [1] => Array ( [0] => 8 [1] => 3 [2] => 4 [3] => 7)
  4. I actually did look in there. I already took several arrays and combined them into two seperate arrays. I'm pretty sure I need to do a nested foreach loop in order to do this. I just don't understand how to do it.
  5. I have two arrays that are listed like this. Array1 ( [0] => Array ( [32347] => 8 [22188] => 3 [37493] => 4 [37201] => 7 ) ) Array2 ( [0] => Array ( [0] => Array ( [0] => 32347 [1] => 28470 [2] => 35319 [3] => 37493 ) [1] => Array ( [0] => 5 [1] => 2 [2] => [3] => 4 ) [2] => Array ( [0] => 484 [1] => 383 [2] => 315 [3] => 320 ) ) ) I want to combine both arrays if value is the same. Example [32347] => 8 => 5 => 484 Thank you in advance.
  6. Thank you very much for your help. I was able to get the script up and running just like I wanted and it works perfect. Shout out to mac_gyver, scootstah, Ch0cu3r, and Barand for assisting me.
  7. First off let me thank everyone for their help so far. After trying a few different things and getting an error message. I figured out that allow_url_fopen is OFF. How would I go about CURL to get the data I'm requesting since I'm pretty sure that would be an alternative option.
  8. Okay I have been playing with this all day and decided to go back to the first script i started with and it's still producing the error. Warning: Invalid argument supplied for foreach() in <?php ini_set('display_errors', 1); error_reporting(-1); $postcode1=('CB13HR'); $postcode2=('CB23JX'); $url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=$postcode2&destinations=$postcode1&mode=driving&language=en- EN&sensor=false"; $data = @file_get_contents($url); $result = json_decode($data, true); foreach($result['rows'] as $distance) { echo 'Distance from you: ' . $distance['elements'][0]['distance']['text'] . ' (' . $distance['elements'][0]['duration']['text'] . ' in current traffic)'; } ?> I also tried to replace json_decode with json_decode( preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $json_string);, true ); and it returned nothing. Thanks for any and all help ahead of time.
  9. I did already try taking that out. I copy and pasted the working original into here since I tried several things and didn't want an self made error. When i turn on error reporting i get Notice: Undefined offset: 1 line 16
  10. Thank you everyone for your help!! I have my code working just as I want on my test hosting server that is running php version 5.2.17. When I move it over to the actual server I want to use it on that is running php version 5.3.29. its not displaying any type of input inside the foreach loop including a simple echo test text. Section of code the issue is in I think $url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=$postcode2&destinations=$postcode1&mode=driving&language=en-EN&sensor=false"; $data = @file_get_contents($url); $result = json_decode($data, true); foreach($result['rows'] as $distance) {; $items2[] = array( 'info' => $distance['elements'][0]['distance'], 'venue' => $venue, 'vid' => $vid, ); } FULL CODE <?php ini_set('display_errors', 1); error_reporting(-1); include 'config/db_functions.php'; //run the query $loop = mysql_query("SELECT * FROM NEW_Venues WHERE game_nights = '5' AND status = '1'") or die (mysql_error()); $items = null; $items1 = null; while ($row = mysql_fetch_array($loop)) { $postcode2 = $row['zip']; $venue = $row['venue']; $vid = $row['vid']; $postcode1=('33462');; $url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=$postcode2&destinations=$postcode1&mode=driving&language=en-EN&sensor=false"; $data = @file_get_contents($url); $result = json_decode($data, true); foreach($result['rows'] as $distance) {; $items2[] = array( 'info' => $distance['elements'][0]['distance'], 'venue' => $venue, 'vid' => $vid, ); } } function sortValues($a, $b) { return strnatcmp($a['info']['text'], $b['info']['text']); } usort($items2, 'sortValues'); $venueid = $items2[0]['vid']; $venuename = $items2[0]['venue']; echo "Sunday - $venuename<br>"; ?>
  11. I'm getting an syntax error, unexpected T_FUNCTION when I add usort($data, function($a, $b) { return strnatcmp($a['text'], $b['text']); }); echo '<pre>',print_r($data, true),'</pre>';
  12. I get this when turning those on. Strict Standards: ksort() [function.ksort]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST'
  13. I'm having an issue sorting an array. I'm getting an error of "Warning: ksort() expects parameter 1 to be array, null given in" The print_r output of the array is Array ( [0] => Array ( [text] => 96.1 km [value] => 96113 ) [1] => Array ( [text] => 52.1 km [value] => 52096 ) [2] => Array ( [text] => 102 km [value] => 102064 ) [3] => Array ( [text] => 30.0 km [value] => 29992 ) [4] => Array ( [text] => 43.9 km [value] => 43864 ) [5] => Array ( [text] => 57.4 km [value] => 57408 ) [6] => Array ( [text] => 82.2 km [value] => 82154 ) [7] => Array ( [text] => 73.6 km [value] => 73620 ) [8] => Array ( [text] => 118 km [value] => 118016 ) [9] => Array ( [text] => 137 km [value] => 136921 ) [10] => Array ( [text] => 61.6 km [value] => 61574 ) [11] => Array ( [text] => 74.2 km [value] => 74193 ) [12] => Array ( [text] => 226 km [value] => 226166 ) [13] => Array ( [text] => 140 km [value] => 140145 ) [14] => Array ( [text] => 126 km [value] => 126140 ) [15] => Array ( [text] => 45.5 km [value] => 45520 ) [16] => Array ( [text] => 211 km [value] => 211070 ) [17] => Array ( [text] => 54.1 km [value] => 54145 ) [18] => Array ( [text] => 187 km [value] => 186855 ) [19] => Array ( [text] => 271 km [value] => 271334 ) [20] => Array ( [text] => 219 km [value] => 218848 ) [21] => Array ( [text] => 67.0 km [value] => 67016 ) [22] => Array ( [text] => 13.6 km [value] => 13591 ) [23] => Array ( [text] => 153 km [value] => 153396 ) [24] => Array ( [text] => 11.5 km [value] => 11492 ) ). All I want to do is be able to sort the array by the lowest number in either text or value and display that single number. <?php include 'config/db_functions.php'; //run the query $loop = mysql_query("SELECT * FROM NEW_Venues WHERE game_nights = '5' AND status = '1'") or die (mysql_error()); while ($row = mysql_fetch_array($loop)) { $postcode2 = $row['zip']; $venue = $row['venue']; $postcode1=('33071');; $url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=$postcode2&destinations=$postcode1&mode=driving&language=en-EN&sensor=false"; $data = @file_get_contents($url); $result = json_decode($data, true); ksort($items); foreach($result['rows'] as $distance) {; echo '' . $venue . ' - ' . $distance['elements'][0]['distance']['text'] . ' <br>'; $items[] = $distance['elements'][0]['distance']; $items1[] = $distance['elements'][0]['distance']; $itemsname[] = $venue; } } ksort($items1); foreach ($items1 as $key => $val) { echo "$key = $val <br>"; } print_r(array_values($items)); ?>
×
×
  • 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.