I want to rewrite a VisualBasic function into a PHP function :
Public Function Convert_Ariary(ByVal g_Valeurs As Double) As Double
Dim partie_entier As Double
Dim partie_decimale As Double
Dim int_pos As Integer
Dim Var_Symbole As String
int_pos = 0
Var_Symbole = vbNullString
int_pos = InStr(1, CStr(g_Valeurs), ",", vbTextCompare)
If int_pos > 0 Then
Var_Symbole = ","
Else
int_pos = InStr(1, CStr(g_Valeurs), ".", vbTextCompare)
If int_pos > 0 Then Var_Symbole = "."
End If
If int_pos > 0 Then
partie_entier = Int(g_Valeurs)
partie_decimale = Round(CDbl(g_Valeurs) - partie_entier, 2)
Select Case partie_decimale
Case 0 To 0 & Var_Symbole & 0 & 9
Convert_Ariary = partie_entier
Case 0 & Var_Symbole & 1 To 0 & Var_Symbole & 2 & 9
Convert_Ariary = partie_entier + 0.2
Case 0 & Var_Symbole & 3 To 0 & Var_Symbole & 4 & 9
Convert_Ariary = partie_entier + 0.4
Case 0 & Var_Symbole & 5 To 0 & Var_Symbole & 6 & 9
Convert_Ariary = partie_entier + 0.6
Case 0 & Var_Symbole & 7 To 0 & Var_Symbole & 8 & 9
Convert_Ariary = partie_entier + 0.8
Case 0 & Var_Symbole & 9 To 0 & Var_Symbole & 9 & 9
Convert_Ariary = partie_entier + 1
End Select
Else
Convert_Ariary = CStr(g_Valeurs) & "." & "00"
End If
End Function
I m stuck at the switch case , how to rewrite the different case expressions into PHP statements because there are the To
keywords ?
You could try greater or equal and less or equal:
case x>=0.1:
case x<=0.9:
{do something}
or
case x>=0.1 && x<=0.9:
{do something}
1: PHP switch case more than 1 value in the case 2:http://sandbox.onlinephpfunctions.com/code/b203b57e563d9f5921aa89fbefdba0aa1f39d4b7