isolate string from variable that contains numbers php -


I am trying to isolate the text of which I have added the variable in which only numbers I saw it And I am not getting anything that works or is close to what I am trying to do. Here I am searching for:

  $ winning = max (array $ $ var1. "Var_One", $ var2. "Var_Two", $ var3. "Var_Tree", $ var4. "Var_Four ")); $ Winning = {Function which I remember}  

I have to get the string with the highest value variable and then use it in a switch case, for example:

  switch (winning $) {case "Var_One": echo "This variable is the highest value."; break; Case "Var_Two": echo "This variable is the highest value."; break; Case "Var_Three": echo "This variable is the highest value."; break; Default: The echo "value is bound."; }  

I tried to use a regedx solution that did not work and I do not want strokes.

Any help is appreciated.

Answer:

  function getMaxValue (array $ list) {$ result = []; Foreach ($ k = & gt; $ list as $ v) {if (! Isset ($ result ["value"]) || $ result ["value"]  $ Var1, "Var_Two" = & gt; $ Var2, "Var_Three" = & gt; $ Var3]; $ Winning = MillXValu (winning $); If (strokes (winning, 'Var_One')! == wrong) {echo "Var_One is currently winning" by $ var1. "!" ;; } And if (strokes ($ winning, 'Var_Two')! == wrong) {echo "Var_Two is currently winning". $ Var2 "!"; } And if (strokes (winning, 'var_Three')! == wrong) {echo "Var_Three is currently winning" $ var3 "!"; } Else {echo "tie."; }  

I think you are looking for something like this:

< Previous> function getMaxValue (array $ list) {$ result = []; Foreach ($ k = & gt; $ list as $ v) {if (! Isset ($ result ["value"]) || $ result ["value"]

Test:

  $ list = ["a" => 2, "two" = & gt; 0, "three" = & gt; 5, "four" = & gt; 4]; Var_dump (getMaxValue ($ list));  

Result:

  array (2) {["value"] = & gt; Int (5) ["key"] = & gt; String (5) "three"}  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -