Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Replacing text with images in PHP script.

Featured Replies

o.k.,

 

I thought I might keep this idea to myself, and develop it on my own to reap all the glory.

 

Here is the idea: Replace text in a given area with images for each letter.

 

Advantages?

Imagine converting a whole page of text to images of the fonts (3-d, shaded, outlined).

 

Here is a sample of the baby script in action: http://fabricstashinc.com/r/

(hint: resize your browser window to see that it is not one image.)

 

please don't laugh at it, I just began! But you get the idea, replace any text with an image representing each letter. The text can have a transparent background if it is a .png.

 

Drupal apparently has a plugin that converts .ttf fonts into images, supposedly achieving something like this, but I think this idea is potentially better, because you can get the perfect image with a graphics editing program such as Adobe Illustrator.

 

Here is what I've got for a script so far:

 

$data = 'decadedecc';


$a[1] = "/a/";
$a[2] = "/b/";
$a[3] = "/c/";
$a[4] = "/d/";
$a[5] = "/e/";



$b[1] = '<img src="a.png" />';
$b[2] = '<img src="b.png" />';
$b[3] = '<img src="c.png" />';
$b[4] = '<img src="d.png" />';
$b[5] = '<img src="e.png" />';



$new = preg_replace($a[3], $b[3], $data);
$new2 = preg_replace($a[2], $b[2], $new);
$new3 = preg_replace($a[1], $b[1], $new2);
$new4 = preg_replace($a[4], $b[4], $new3);
$new5 = preg_replace($a[5], $b[5], $new4);


echo $new5;

 

I would like to convert to object oriented approach, but I need a bit more learning first. The main problem with the script as it looks now, is that as it replaces the text with the images, letters in the html brackets start getting replaced with images of the letter, which is why I replace the letter 'c' first.

 

Obviously most programmers are way ahead of me, but if you could give some advice on how to best achieve the end result I am looking for.

What advantage will you achive with this system over js/flash text replacement like Sifr?

This is a cross-post. The topic already exists at http://www.webdesignerforum.co.uk/index.ph...c=17433&hl=.

As does the intended script: http://code.google.com/p/pcdtr/

 

What advantage will you achive with this system over js/flash text replacement like Sifr?

Such scripts allow interesting typography to be used on websites without the designer needing to write each piece of text in a program such as Photoshop. The user does not need to download an additional piece of software such as Flash Player, which may not be possible on a public machine, or a very old one.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.