Jump to content

format

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by format

  1. if(is_numeric($tmp2[0]))// ignore non number $maxLevels[] = $tmp2[0]; // add JLevel to array Thanks requinix. I have it working. I had a typo which.
  2. Thanks for reply, ya Im not in control of the data. Its coming from a live quote system and they replace what should be a numberwith a text message for any companies that dont return a quote. I tired the below but I think the problem here is I just dont understand how it should work.. I can use is_numeric and even concidered strpos but no joy. Im trying to only add to the array numbers. if(is_numeric($tmp[0])) $maxLevels[] = $tmp[0];
  3. Hi All, I am using the below with great success. It finds for me the MIn and max values allong with the company names. The problem that has just presented itself is some of the data returned in the SLevel is text. I need to ignore text and only include numeric values. Is this possible. I have tried to work this out but have hit a brick wall. Many thanks Jon $SLevels = array(); foreach ($xml->Type->Company as $item) { $companyName = (string) $item->Name; // get the company name $tmp = (array) $item->$Level; if($tmp[0] != '-') $SLevels[] = array($tmp[0], $companyName); // add SLevel and company name to array } $minSLevel = min($SLevels); // get minimum value $minSLevel[0] = str_replace(',', '', $minSLevel[0]); $premium = $minSLevel[0]; $company = $minSLevel[1]; $maxSLevel = max($SLevels); // get minimum value $maxSLevel[0] = str_replace(',', '', $maxSLevel[0]); $maxpremium = $maxSLevel[0]; $maxcompany = $maxSLevel[1];
  4. Many thanks to you all for your replies. Lots to take in. cyberRobot, I tried your suggestion and it worked a charm. Barrand, your suggetion also make sperfect sence. Thank you for this. Good help like this is worth its weight in gold, especialy when on the back foot with time. Thanks again. Jon
  5. Hmmm,all I want is to find the Zurich Life entry and its matching quote. Thats it really. Sorry if not using correct terms etc.
  6. Thanks for the quick answer, a few options to read and learn. Would you know which option above would get me going the quickest. I had a quick look at the documentation and could see how to get the value of [0] and matching [1]. I suspect I have some reading ahead of me, just not sure which methos above I should start with. Many thanks Jon
  7. Hi Guys, I got great help here a few years ago and I wonder if I can ask another related question. I am using the floowing to get the smallest quote from the array below: $minSLevel = min($SLevels); // get minimum value $minSLevel[0] = str_replace(',', '', $minSLevel[0]); Array ( [0] => Array ( [0] => 35.18 [1] => Royal London ) [1] => Array ( [0] => 34.18 [1] => Zurich Life ) [2] => Array ( [0] => 32.74 [1] => Friends First ) [3] => Array ( [0] => 39.13 [1] => Aviva ) [4] => Array ( [0] => 40.59 [1] => Irish Life ) [5] => Array ( [0] => 35.26 [1] => New Ireland ) ) Works great. Is it possible to filter the above to find value of [0] where [1] = Zurich Life Many thanks for any help given. Very much appreciated. Jon
×
×
  • 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.