Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:31:50+00:00 2026-06-17T21:31:50+00:00

Hopefully someone will be able to tell me how to keep user quotes when

  • 0

Hopefully someone will be able to tell me how to keep user quotes when generating an image. What I mean is if a user submits words like:

don’t

or

John said “hello”

how can I keep them in the generated image. Currently it turns to

don\t

Here is my code:

<?php


function formattextimg( $text, $width = 960, $color = array( 0, 0, 0 ),$bgcolor = array( 255, 255, 255 ), $font = 2 ) {
$width = ( ( isset( $width ) && is_numeric( $width ) ) ? ( ( $width >= 100 ) ? (int)$width : 100 ) : 960 );
$text = str_replace( array( '<b>', '</b>', '<strong>', '</strong>' ), '|', $text );
$text_b = preg_split( '/\|/', $text, -1, PREG_SPLIT_OFFSET_CAPTURE );
foreach($text_b as $k => $tb){if($k%2!=0){$textbold[($tb[1]-1)]=$tb[0];}}
$text = str_replace('|','',$text);
for( $i = 0; $i < strlen( $text ); $i++ ) {
    if( $string_c >= ( $width - ( (int)(imagefontwidth( $font ) / 2 ) ) ) ) {
        $space = strrpos( $string, ' ' );
        $string_sub = substr( $string, 0, $space );
        $i = $i - ( strlen( $string ) - $space ) + 1;
        $strings[] = $string_sub;
        $string = '';
        $string_c = 0;
    }
    $string .= $text{$i};
    $string_c += imagefontwidth( $font );
}
$strings[] = $string;

$im = imagecreatetruecolor( $width, ( imagefontheight( $font ) * ( count( $strings ) ) ) );
imagesavealpha( $im, true );
$trans = imagecolorallocate( $im, $bgcolor[0], $bgcolor[1], $bgcolor[2] );
imagefill( $im, 0, 0, $trans );
$color = imagecolorallocate( $im, $color[0], $color[1], $color[2] );
$black = imagecolorallocate( $im, 0, 0, 0 );
foreach( $strings as $pos => $string ) {
    imagestring( $im, $font, 5, ( $pos * imagefontheight( $font ) ), $string, $color );
}
$len = 0;
foreach( $strings as $pos => $string ) {
    $len += ( strlen( $string ) + 1 );
    if( count( $textbold ) > 0 ) {
        foreach( $textbold as $cpos => $word ) {
            if( $cpos <= $len ) {
                $wpos = strpos( $string, $word );
                if( $wpos !== false ) {
                    imagestring( $im, $font, 
                        ( $wpos * imagefontwidth( $font ) )+1, 
                        ( ( $pos ) * imagefontheight( $font ) ), 
                        $word, $color
                    );
                        unset( $textbold[$cpos] );
                    }
                }
        }
        }
    }
    return $im;
}

header( 'Content-type: image/png' );
imagepng( formattextimg( $text,300,array( 255, 255, 255 ),array( 128, 128, 128 ),16 ) );
exit;
?>

If that is not possible can someone please tell me how to remove the:

‘

and

“

I tried:

$text=$_REQUEST['text'];
$text=str_replace('"', "", $text);
$text=str_replace("'", "", $text);

But it did not work.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:31:51+00:00Added an answer on June 17, 2026 at 9:31 pm

    This is caused by magic_quotes_gpc being enabled on the server.

    You can reverse the effect of magic_quotes_gpc by calling stripslashes if get_magic_quotes_gpc (manual) returns true:

    $text = $_REQUEST['text'];
    
    if (get_magic_quotes_gpc())
    {
        $text = stripslashes($text);
    }
    

    It’s important that you actually check the value of get_magic_quotes before calling stripslashes, as this feature has been deprecated in PHP 5.3 and removed altogether from PHP 5.4.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't even know if this is possible but hopefully someone will be able
Hopefully someone here will be able to help me with a problem that I'm
Hopefully someone will be able to point me in the right direction - I
Hopefully someone will be able to help me with this! I'm trying to get
This could be a very basic question, but hopefully someone will be able to
Good afternoon, hopefully someone will be able to assist me in diagnosing an issue
Hopefully someone can help me. I'm attempting to do the following: If a user
i got problem with my code and hopefully someone able to figure it out.
Hopefully someone may be able to quickly advise the best way for me to
I am hoping someone will be able to point me in the right direction.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.