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 6202515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:44:58+00:00 2026-05-24T04:44:58+00:00

It basically comes down to this. I have a string called $name. $name usually

  • 0

It basically comes down to this. I have a string called $name. $name usually has the value ”blablabla”, the value comes from an external resource so that’s why it’s encapsulated in two single quotes. If i would declare this variable myself it would look like this:
$name = "''blablabla''";

I am deleting these single quotes by:

$name[0] = '';
$name[1] = '';
$name[mb_strlen($name, 'UTF-8')-1] = '';
$name[mb_strlen($name, 'UTF-8')-2] = ''; 

(unsetting the string with a index doesn’t work)
So now I have $name with value “blablabla” without the signle quotes.
Here’s my problem.
When I look at the source code, there are strange characters before the “blablabla”.
How can I deal with this?
And, is there any way to reindex my string (for example what array_values does for arrays)?

EDIT
Eventually I used this code :

$name = mb_substr($name, 2, -2, 'UTF-8');
  • 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-05-24T04:44:59+00:00Added an answer on May 24, 2026 at 4:44 am
    $name = "''foo''";
    
    $name = substr($name, 2, -2);
    
    echo $name; # foo
    
    1. You’re dealing with encodings, while the characters in question (') are single-byte. Strings in PHP are still binary only, which means, you can just cut it off at the ends.
    2. When you unset using the index, keep in mind that it’s the binary position. mb_strlen does not suit to gather the binary index position, strlen does:

    .

    $name = "''foo''";
    
    $name[0] = '';
    $name[1] = '';
    
    $len = strlen($name); # binary safe string length
    
    $name[$len-1] = '';
    $name[$len-2] = '';
    
    echo $name; # foo
    

    mb_strlen compared with strlen

    $utf8 = 'ä';
    mb_strlen($utf8, 'UTF-8'); # 1
    strlen($utf8);             # 2
    
    $utf8[1] != 'ä';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, basically I have this select / drop down menu that I use AJAX
Basically the problem comes down to this: I load a file, write all the
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
I have a table I am trying to generate reports from. Its basically a
Let's say my SQL database contains a table called 'Customer'. This Customer has an
We are building a configurator application for conveyors. Basically user comes in and picks
So I'm basically a beginner when it comes to Vim, nonetheless I do know
Basically what I want to do it this: a pdb file contains a location
Basically I have some code to check a specific directory to see if an
Basically I am trying to restart a service from a php web page. Here

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.