php - Simple Array Sum Not Working -



php - Simple Array Sum Not Working -

function regex_scrape($regex,$results_page){ preg_match_all($regex,$results_page,$match); homecoming $match; } $continue = true; $prices = array(); $url = ""; while ($continue == true) { $results_page = curl($url); // downloading results page using our curl() funtion $prices2 = regex_scrape('/<span class=\"h3 price-amount\">(.*)span>/',$results_page); $prices = array_merge($prices,$prices2[0]);

array looks , can't array_sum or find lowest array value (min)

array ( [0] => 45 [1] => 80 [2] => 60 [3] => 40 [4] => 37 [5] => 69 [6] => 34 [7] => 79 [8] => 46 [9] => 91 [10] => 269 [11] => 59 [12] => 60 [13] => 79 [14] => 35 [15] => 67 [16] => 85 [17] => 45 )

echo array_sum($prices); returns 0 why?

your illustration array not have consecutive indexes (probably array_merge). have tried doing array_values first?

echo array_sum(array_values($prices));

php

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -