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

  • Home
  • SEARCH
  • 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 8030097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:39:26+00:00 2026-06-05T00:39:26+00:00

I am grabbing input from a file with the following code $jap= str_replace(\n,,addslashes(strtolower(trim(fgets($fh), \t\n\r))));

  • 0

I am grabbing input from a file with the following code

$jap= str_replace("\n","",addslashes(strtolower(trim(fgets($fh), " \t\n\r"))));

i had also previously tried these while troubleshooting

$jap= str_replace("\n","",addslashes(strtolower(trim(fgets($fh)))));
$jap= addslashes(strtolower(trim(fgets($fh), " \t\n\r")));

and if I echo $jap it looks fine, so later in the code, without any other alterations to $jap it is inserted into the DB, however i noticed a comparison test that checks if this jap is already in the DB returned false when i can plainly see that a seemingly exact same entry of jap is in the DB. So I copy the jap entry that was inserted right from phpmyadmin or from my site where the jap is displayed and paste into a notepad i notice that it paste like this… (this is an exact paste into the below quotes)

”

バスにのって、うみへ行きました”

and obviously i need, it without that white space and breaks or whatever it is.

so as far as I can tell the trim is not doing what it says it will do. or im missing something here. if so what is it?

UPDATE:
with regards to Jacks answer

the preg_replace did not help but here is what i did, i used the
bin2hex() to determine that the part that “is not the part i want” is
efbbbf
i did this by taking $jap into str replace and removing the japanese i am expecting to find, and what is left goes into the bin2hex. and the result was the above “efbbbf”

echo bin2hex(str_replace("どちらがあなたの本ですか","",$jap));

output of the above was efbbbf
but what is it? can i make a str_replace to remove this somehow?

  • 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-05T00:39:29+00:00Added an answer on June 5, 2026 at 12:39 am

    The trim function doesn’t know about Unicode white spaces. You could try this:

    preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $str);
    

    As taken from: Trim unicode whitespace in PHP 5.2

    Otherwise, you can do a bin2hex() to find out what characters are being added at the front.

    Update

    Your file contains a UTF8 BOM; to remove it:

    $f = fopen("file.txt", "r");
    $s = fread($f, 3);
    if ($s !== "\xef\xbb\xbf") {
        // bom not found, rewind file
        fseek($f, 0, SEEK_SET);
    }
    // continue reading here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm grabbing lines from a text file and sifting line by line using regular
I'm grabbing input from a standard input stream. Such as, 1 2 3 4
Grabbing delimited dates from database and adding new ones to the list, then want
I am grabbing a feed from API and and here I want to get
I'm grabbing a row from the the db in a wordpress plugin using: $ongoing_event
I have jquery grabbing an id from something else (image) and I would like
I am grabbing some values from my database and putting them in a drop
I am grabbing an HTMLElement from a browser object and then using getElementById to
I have the following HTML <input type=text name=first expression=firstExpression/> <input type=text name=last expression=secondExpression/> <input
I'm grabbing video frames from the camera via v4l, and i need to transcode

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.