I have a PHP page which gets text from an outside source wrapped in quotation marks. How do I strip them off?
For example:
input: "This is a text"
output: This is a text
Please answer with full PHP coding rather than just the regex…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
This will work quite nicely unless you have strings with multiple quotes like
"""hello"""as input and you want to preserve all but the outermost"‘s:trim strips all of certain characters from the beginning and end of a string in the charlist that is passed in as a second argument (in this case just
"). If you don’t pass in a second argument it trims whitespace.If the situation of multiple leading and ending quotes is an issue you can use:
Which replaces only one leading or trailing quote with the empty string, such that:
""This is a text""becomes"This is a text"