...

View Full Version : GD variable with spaces(" ") please



student101
07-22-2008, 07:53 PM
How do I take this and add spaces in between?
This outputs a 5 digit number like this: 28641

if(!isset($_SESSION)) {
session_start(); }
$text = rand(10000,99999) ;
$_SESSION["thecode"] = $text;

$height = 25;
$width = 55;

$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p, 255, 255, 255);
$white = imagecolorallocate($image_p, 255, 0, 0);
$font_size = 12;
imagestring($image_p, $font_size, 5, 10, $text, $white);
imagejpeg($image_p, null, 100);
I would like to make this: 2 8 6 4 1 - just add spaces.

Cheers

kbluhm
07-22-2008, 08:15 PM
$text = '28641';

$text = str_split( $text );

$text = implode( ' ', $text );

echo $text; // 2 8 6 4 1

student101
07-22-2008, 08:20 PM
WOW! that simple?
I have been searching for hours on the PHP GD page for an idea.

Thank you!

Cheers



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum