Checking an array against user input?

From: Date: Wed, 27 Feb 2008 05:36:09 +0000
Subject: Checking an array against user input?
Groups: php.general 
Request: Send a blank email to php-general+get-270253@lists.php.net to get a copy of this message
Hello all, I am new to this news group, and figured this was the fastest way to get a good, helpful answer. Here is my problem: I have an array that I set up with numbers 00 thru 99. Now, I have some timestamps that look somewhat like this: [00:01:70] [00:06:50] [00:12:07] [00:15:04] [00:19:75] I am making a script that will convert them into this: [00:01.70] [00:06.50] [00:12.07] [00:15.04] [00:19.75] (notice the period ( . ) instead of the colon ( : ) after the fourth number) My problem is that I don't know how to achieve this. This is the code I have so far: $nums = array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "00"); $x = array_search($nums,$nums); $format1 = array("[$x:$x:$x]", "[$x:$x.$x]"); $format2 = array("[$x:$x.$x]", "[$x:$x:$x]"); It is linked up with a textbox and a button if that matters any. I just need to beable to have the script look at the array, and match it with whatever the user types in. Unless there is a different way to get what I need? Thank you, Keikonium

« previous php.general (#270253) next »