Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts

    Question GD variable with spaces(" ") please

    How do I take this and add spaces in between?
    This outputs a 5 digit number like this: 28641
    PHP Code:
    if(!isset($_SESSION)) { 
    session_start(); }
    $text rand(10000,99999) ;
    $_SESSION["thecode"] = $text;

    $height 25;
    $width 55;
     
    $image_p imagecreate($width$height);
    $black imagecolorallocate($image_p255255255);
    $white imagecolorallocate($image_p25500);
    $font_size 12
    imagestring($image_p$font_size510$text$white);
    imagejpeg($image_pnull100); 
    I would like to make this: 2 8 6 4 1 - just add spaces.

    Cheers
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    PHP Code:
    $text '28641';

    $text str_split$text );

    $text implode' '$text );

    echo 
    $text// 2 8 6 4 1 

  • Users who have thanked kbluhm for this post:

    student101 (07-22-2008)

  • #3
    Regular Coder student101's Avatar
    Join Date
    Nov 2007
    Posts
    634
    Thanks
    80
    Thanked 15 Times in 15 Posts
    WOW! that simple?
    I have been searching for hours on the PHP GD page for an idea.

    Thank you!

    Cheers
    Thanks for your support!
    Update MySQL with checkboxes | Tell A Friend | Delete MySQL with checkboxes

    Give thanks & resolve when done :thumbsup:


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •