Re: looping through text with array_key_exists function
- From: "-Lost" <spam_ninjaREMOVEME@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 16:33:27 -0400
I hate to beat a dead horse (if it was in fact), but what I meant earlier was that
creating a huge array may not have been your best choice. As you will always have to
compare your string against an array before outputting.
Whereby, I meant something along these lines:
<?php
$string = 'one two three four five six seven eight nine ten';
$string_into_pictures = explode(' ', $string);
foreach($string_into_pictures as $s2p)
{
$s2ps[] = str_split($s2p);
}
for($i = 0; $i < count($s2ps); $i++)
{
for($j = 0; $j < count($s2ps[$i]); $j++)
{
print $s2ps[$i][$j] . '.jpg<br />' . "\n";
//print '<img src="' . $s2ps[$i][$j] . '.jpg" alt="' . $s2ps[$i][$j] . '" />' . "\n";
}
print 'empty.jpg<br />' . "\n";
//print '<img src="empty.jpg" alt="space" />' . "\n";
}
?>
When you said you cannot explode a space it made me think "yes you can, sorta". Granted,
this may not be the best approach nor even fastest. I have found though that arrays and
regexps just for the sake of them does not mean better; faster; cleaner or anything for
that matter. Not saying they are bad though, understand the difference. Anyway... hope
this helps a bit.
-Lost
P.S. Oh yeah... I used the first prints as debug basically. Comment them and uncomment
the second to get your lovely images.
.
- References:
- looping through text with array_key_exists function
- From: drako
- Re: looping through text with array_key_exists function
- From: drako
- Re: looping through text with array_key_exists function
- From: Janwillem Borleffs
- Re: looping through text with array_key_exists function
- From: drako
- Re: looping through text with array_key_exists function
- From: drako
- Re: looping through text with array_key_exists function
- From: Janwillem Borleffs
- Re: looping through text with array_key_exists function
- From: drako
- looping through text with array_key_exists function
- Prev by Date: Re: looping through text with array_key_exists function
- Next by Date: Re: Connect to mysql?
- Previous by thread: Re: looping through text with array_key_exists function
- Next by thread: need help with a new site
- Index(es):
Relevant Pages
|