Jump to content

Building strings


The Little Guy

Recommended Posts

This just really shows how geeky php freaks we really are, ha ha.

 

I just did this up so can do ranges in groups with being able to set lower and maximum limits for the groups.

I only played with it a little bit, so just be careful with it, ehh, maybe set an extreme maximum limit to it or something.

 

I was doing by letter and letter position amounts but I quit on it.

Something like start from rrrr to rzzz or similar.

 

<?php
$group = mysql_real_escape_string($_GET['group']);
if (!isset($_GET['group']) or $_GET['group'] == '') {
$group = 1;
}
$lower = mysql_real_escape_string($_GET['lower']);
$increase = mysql_real_escape_string($_GET['increase']);

$alphabet_count = 26;
$maximum_range = $alphabet_count*$group;
$minimum_range = $maximum_range-25;
$increase = $maximum_range+$increase;
?>

<form name="input" action="" method="get">
Group:<input size="30"type="text" name="group" style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="<?php echo $group; ?>">
Lower:<input size="30"type="text" name="lower" style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="<?php echo $lower; ?>">
Increase:<input size="30"type="text" name="increase" style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="<?php echo $increase; ?>">
<input type="submit" style="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #000000;" size="15" value="Set" />
</form>

<?php
function seqAlphabet($numbers)
{
  $alphabet = '';
  while($numbers >= 1) {
    $numbers = $numbers - 1;
    $alphabet = chr(($numbers % 26)+97) . $alphabet;
    $numbers = $numbers / 26;
  }
  return $alphabet;
}

$string_position = range($lower,$increase);
foreach ($string_position as $position) {
echo seqAlphabet($position) . "<br />";
}
?>

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.