Re: Checking an array against user input?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am a bit confused by your code, Rob. The timestamps will always change (and have text after them) and that is what I am trying to take into account. Perhaps having my entire code might be of more use:

<html>
<head>
<title>Lyrics Editor</title>

<?php
$letters = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); $lower = array("aint", "i've", "i'd", " id ", "i''ll", " ill ", " dont ", "i'm", " im ", " i ", "]a", "]b", "]c", "]d", "]e", "]f", "]g", "]h", "]i", "]j", "]k", "]l", "]m", "]n", "]o", "]p", "]q", "]r", "]s", "]t", "]u", "]v", "]w", "]x", "]y", "]z"); $upper = array("ain't", "I've", "I'd", " I'd ", "I''ll", " I'll ", " don't ", "I'm", " I'm ", " I ", "]A", "]B", "]C", "]D", "]E", "]F", "]G", "]H", "]I", "]J", "]K", "]L", "]M", "]N", "]O", "]P", "]Q", "]R", "]S", "]T", "]U", "]V", "]W", "]X", "]Y", "]Z");

$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]");

$textarea = '';
//****************************
if (isset($_POST['uppercase']))
{
$textarea = $_POST['entry'];
$textarea = str_replace($lower, $upper, $_POST['entry']);
}
//****************************
else if (isset($_POST['format1']))
{
$textarea = $_POST['entry'];
$textarea = str_replace($format1, $format2, $_POST['entry']);
}
//****************************
else if (isset($_POST['format2']))
{
$textarea = $_POST['entry'];
$textarea = str_replace($format2, $format1, $_POST['entry']);
}
//****************************
?>

</head>
<body>

<FORM NAME ="form1" METHOD ="POST" ACTION ="lyricseditor.php">
<textarea name="entry" cols="70" rows="20"><?PHP print stripslashes($textarea); ?></textarea> <p>Convert first letter to uppercase: <input type="submit" name="uppercase" value="Convert..."></p> <p>Convert to [xx:xx:xx] format: <input type="submit" name="format1" value="Convert..."></p> <p>Convert to [xx:xx.xx] format: <input type="submit" name="format2" value="Convert..."></p>
</FORM>

</body>
</html>


"Robert Cummings" <robert@xxxxxxxxxxxxx> wrote in message news:1204092181.18306.1113.camel@xxxxxxxxxx

On Wed, 2008-02-27 at 00:36 -0500, Keikonium wrote:
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]

$newTimestamp = $oldTimestamp;
$newTimestamp[5] = '.';

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux