The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
formatting all int values of an array
would this be the best way to do it, or do you know a better way to do it?
PHP Code:
|
#2
|
|||
|
|||
What do you want to have happen when...
Code:
$value = 1000.01; $value = 0; $value = '1a'; $value = ''; |
#3
|
||||
|
||||
1,000,000 or whatever the vb_number_format() is set at via the $vboptions.
|
#4
|
|||
|
|||
Code:
foreach($array AS $key => $value) { $value = intval($value); $array[] = ($value > 999) : vb_number_format($this->GetStats[$value]) ? $value; } |
#5
|
||||
|
||||
the only problem with that is that the $value could be 1, 5, 1million or 1billion, also in the array theirs also string values which don't need to be number formatted.
|
#6
|
|||
|
|||
Code:
foreach($array AS $key => $value) { if (is_numeric($value)) { $value = intval($value); $array[] = ($value > 999) : vb_number_format($this->GetStats[$value]) ? $value; } else { $array[] = $value; } } |
#7
|
||||
|
||||
ahhh is_numeric was the function i was looking for, thank you calorie
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|