0

I am currently replacing spaces with an underscore during an image upload. How can I also include it so it changes & to "and".

$newname = str_replace( ' ', '_', trim( strip_tags( $_POST['name'] ) ) ) . _ . $formKey->generateKey() . '_' . time() . '.jpg';

Kind of stuck with this one and don't know what to even attempt..

1 Answer 1

2

$newname = str_replace(array(' ', '&'), array('_', 'and'), ... );

Sign up to request clarification or add additional context in comments.

2 Comments

I think you meant the other way around. Replace spaces with an underscore, not "&". Also, replace "&" with "and.
@cillosis The above replaces spaces with underscores and & with "and". PHP: str_replace

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.