How do you remove the new line code (
) with php?

March 05, 2017, at 2:57 PM

Ok, so I was tasked with created a gallery, using a sql table is not an option, so I am doing what I can. This is my code, wich works fine, but it generates a hidden character at the end of every imate.

    $photos = file("/elements/photos.php");
    for ($i = 0; $i < count($photos); $i++) {
    $allimages .= $imagefile =  '<img src="/elements/photos/'.$photos[$i].'">';};

This is the code that it generates

<img src="/elements/photos/t/a_little_kitten.jpg&#10;">

I have been unable to find what this means, I believe it means "blank space" or "new line", but I cannot find it.

This is the code I have tried, but it does not work either.

$allimages = preg_replace('/\s\s+/', ' ', $allimages)

Please help.

Below is the php file I am pulling the image names from. There is no code in this file, just text.

Answer 1

Try rtrim link or trim to remove the whitespace. As I can see that there is a whitespace at the end of your a_little_kitten.jpg and black_cat.jpg file.

&#10 represents a line feed. Maybe you can use str_replace() ex: str_replace(array("\n", "\r"), '', $photos) before for loop.

Rent Charter Buses Company
PHP separated login for admin users

PHP separated login for admin users

someone helped on how to implement my login using different table but now i want different user in the specific table for example the stock manager has a separate page and separate page for the adminheres my code hope you understand just tell me if need to re edit for some reason

PHP Unable to retrieve data using GET Method

PHP Unable to retrieve data using GET Method

I am new to PHP, today I was trying to implement a get methodI am trying to get data based on a token that already exists but, unable to retrive data

while loop output increasing digits and break

while loop output increasing digits and break

i have here a problem that needs to output the same pattern as below