Jump to content

lemaster777

Members
  • Posts

    25
  • Joined

  • Last visited

lemaster777's Achievements

Member

Member (2/5)

0

Reputation

  1. Uhg.. Ok, learning more as I go. If I just switch the $y=$b2 - $a2; around to $y = $a2 - $b2; then it works. I can not thank you enough for helping me muddle through this. Not having access to the original authors source code for webservice api and other portions of this site, combined with my lack of php knowledge is making this a great adventure. Thanks again.
  2. Ok, here is where I stand, and I think I am over the initial roadblock. 1. I have the simplexml into an array. This is working. $sortable = array(); foreach ($table as $case) { $sortable[]=$case; } usort($sortable, function($a, b$) { //I DID THIS TO TEST. The sort was not seeing the $a, $b as a string //so I did the following $test1 = (string)$a->DOCKETID; // This got me just the element we want to sort on $test2 = (string)$b->DOCKETID; // This got me just the element we want to sort on list($a1, $a2, $a3) = splitParts($test1); // Calling the function you provided below list($b1, $b2, $b3) = splitParts($test2); $x = strcmp($a1, $b1); if ($x == 0) { $y = $b2 - $a2; if ($y == 0) { return $b3 - $a3; } return $y; } return $x; }); function splitParts($s) { $k = strlen($s); $a = ['','','']; $i = 0; $p = 0; while ($i < $k) { $c = $s[$i++]; if (ctype_digit($c) && $p==0) $p = 1; if ($c=='-') { $c = $s[$i++]; ++$p; } $a[$p] .= $c; } return $a; } NOW - The last piece of my confusion. The results we want this time are as below. The original sort is what we wanted in my initial request, and that worked great. The piece I'm stuck on now is to sort differently, as below. What we want: CP2015-75 CP2015-76 CP2015-86 CP2015-93 CP2015-102 CP2015-106 CP2015-114 CP2016-3 CP2016-237 CP2016-238 CP2016-241 CP2016-242 CP2016-246 MC2016-164 MC2016-167 What we are getting: CP2016-246 CP2016-242 CP2016-241 CP2016-238 CP2016-237 CP2016-3 CP2015-114 CP2015-106 CP2015-102 CP2015-93 CP2015-86 CP2015-76 CP2015-75 MC2016-167 MC2016-164
  3. If I just call the webservice that is supposed to generate the XML, attached is the XML RAW results, but not from the functions I presented. GetDailyListingSummary.xml
  4. I know this is a pain, but I did the following: $result->GetDailyListingSummaryResult->any and I did a var_dump($result) Here it is attached, just a long string.... VarDumpResult.txt
  5. This is what the API they have is returning. It returns object from simplexml. That's all I can give you, below is the function that generates this: function GetDailyListingSummary($filterdate) { //ini_set('soap.wsdl_cache_enable', '0'); $x = new SoapClient(variable_get('prcwebservice'),variable_get('soapauth')); // make an API call and get data $result = $x->GetDailyListingSummary(array('docDate'=>$filterdate)); // Interpret the XML response $apiresult = simplexml_load_string($result->GetDailyListingSummaryResult->any); $dockets = $apiresult->DailyListingSummary->DailyListingData; return $dockets; }
  6. Ok, first---- Thanks for all the help. Second, I have the following: I get the data into an array and then apply your function. I must need to sort or pass in one of the array columns. I do not get an error, but I also do not get the result. $table should contain the data from XML. I then put it into an Array and apply the function: foreach($table as $case) { $sortable[] = $case; } var_dump($sortable); 'I HAVE ATTACHED THE RESULTS TO THIS usort($sortable,function($a,$b) { list($a1, $a2, $a3) = splitParts($a); list($b1, $b2, $b3) = splitParts($b); $x = strcmp($a1, $b1); if ($x == 0) { $y = $b2 - $a2; if ($y == 0) { return $b3 - $a3; } return $y; } return $x; }); 'NOW I LOOP THROUGH $sortable to display results foreach($sortable as $case) { 'write out results to a table......... } DailyVarDump.txt
  7. The file I posted earlier is all I have, the simple_xml is coming from someone else's compiled call to a database. Longer sigh...
  8. My issue is with getting xml into an array now..
  9. http://php.net/manual/en/book.simplexml.php
  10. I'm with you on that... I'm thinking it can somehow be loaded into a regular array, sorted and then used as normal.
  11. Ok, this all worked in the area I needed. Thank you endlessly for that. Now I have another section of code, that does not seem to work. It is the same principle but the code runs elsewhere. When I place your function in the code, it fails. This is must be inline php issue or something. Attached is the var_dump and var_export of the data. It must be something different, as I can not seem to get the code to work on this data set. Array-Sample2-varExport.txt Array-Sample2-varDump.txt
  12. I just had wrong code in wrong place.
  13. Ok, as I said, I am new to PHP. I had to move the function you provided out of the function I placed it in. Working now. Let me look at results in a few places and confirm.
  14. Attached is the full set of code. Must be something wrong is the syntax on my end. Fill-ID.txt
×
×
  • 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.