Unstoppable Domains โ€” Expired Auctions

PHP Regexs (I presume) help needed

Spaceship Spaceship
Watch

n0dice

Established Member
Impact
0
Hey all. Basically what I'm trying to do is take a text string generated from form and take each individual alphanumeric character and replace it with the corrosponding image. So if 'cat' is typed in it displays '<img src="c.gif"><img src="a.gif"><img src="t.gif">. The images would be transparent gifs of the corrosponding letter from a specific font. Is this possible and how might i do it? Thanks.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Well you don't really need a regex here...
Basically you need to 'scan' your string one letter at a time - a simple loop will do the job nicely ;)
PHP:
<?php

$input_string=$_POST['your_text_field_name_here']; // => here put the name of the input field as defined in your HTML form
$string_length=strlen($input_string); // check length of input string
if ($string_length > 0 ) {
	 for ($count = 0; $count < $string_length; ++$count) {
	 echo '<img src="'.substr ($input_string, $count, 1 ).'.gif">';
	 }
}

?>
 
1
•••
very clever! :) well done - have been looking for something like this for a long, long time, and just never thought to use substr. I was stuck trying to find a way to use explode! :lol:
sdsinc said:
Well you don't really need a regex here...
Basically you need to 'scan' your string one letter at a time - a simple loop will do the job nicely ;)
PHP:
<?php

$input_string=$_POST['your_text_field_name_here']; // => here put the name of the input field as defined in your HTML form
$string_length=strlen($input_string); // check length of input string
if ($string_length > 0 ) {
	 for ($count = 0; $count < $string_length; ++$count) {
	 echo '<img src="'.substr ($input_string, $count, 1 ).'.gif">';
	 }
}

?>
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back