Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a field that users can enter whatever hey want, And I would allow them for decoration using special characters. but Now I really face with a big problem!
Special characters are like this: ♥♦☻NAME☻♦♥
And my really problem is 'alt+255' characters. it's like space and there are so many special characters like space. by the way My links are disabled and no one could select it.
There is a mandatory to enter more than only 1 character,
I want to know how to prevent this problem. my exact mean How can I let users enter special characters but still my links are clickable
If you are including the text in URLs then you really have two options. The most common approach is to strip out everything except for letters, numbers, dashes, and underscores (i.e. don't allow any special characters at all). You could use a simple regular expression replacement to do that.
Alternatively, you could allow all special characters, but escape them for use in links. You will find PHP's urlencode() and urldecode() useful for that.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am writing an unsubscribe option of email newsletters.
I have to detect emails of following format:
<0 or more alphanumeric letter/digit only>, then one <#> character, then <1 or more alphanumeric letter/digit>, then a <.> character, then <at least 2 alphanumeric letter/digits>
I need "zero" or more alphanumeric character before # character and not "one" or more because sometimes I want to unsubscribe whole domain names, so in that case the pattern to match is #example.com, and I also want to detect full email, it starts with an alphanumeric character.
How can I write the code to detect?
I take the email from url as $_GET['email']
For example url will be:
http://www.example.com/php/unsubscribe.php?email=#example.com
http://www.example.com/php/unsubscribe.php?email=#example.co
http://www.example.com/php/unsubscribe.php?email=abc#example.co
well the Regex then simply reads
/#.+\.[^\.]{2,}$/
EDIT: I used .* and [^\.] even though the OP asked for "alphanumeric letter/digit" - however, valid E-Mail addresses include stuff like dashes, underscores etc... Completely matching ALL valid email adresses is incredibly complex! (see: http://www.regular-expressions.info/email.html)
You could use the below regex.
[A-Za-z0-9]*#[A-Za-z0-9]+\.[A-Za-z0-9]{2,}
DEMO
[A-Za-z0-9]{2,} matches two or more alphanumeric characters. You could specify the character range inside {} paranthesis.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a form that asks for money entered and would like to have it formatted correctly with $, commas every 3 places, and no decimals unless applicable. The trouble is that some users enters them correctly while others do not. How do I check in php to see if this number is in the proper format and if it is not, adjust it accordingly. I've already placed the $ to precede the number, just need help with commas and decimal places.
I've heard it's easier to use number_format rather than money_format. Is there a benefit to use one over the other?
"some users enters them correctly while others do not"
Check on input and you're done, just use number_format afterwards to format the number as you like.
To use money_format you need to have your locales properly configured, if you're just using $, number format is easier.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Could somebody tell me the regular expression for replacing everything outside of quote marks with white space?
Example text :
permalink_title='$permalink_title',
code_size_3='$code_size_3',
code_size_3='$code_size_3',
code_size_35='$code_size_35',
code_size_4='$code_size_4',
code_size_45='$code_size_45',
code_size_5='$code_size_5',
code_size_55='$code_size_55',
code_size_6='$code_size_6',
code_size_65='$code_size_65',
code_size_7='$code_size_7',
code_size_75='$code_size_75',
code_size_8='$code_size_8',
code_size_85='$code_size_85',
code_size_9='$code_size_9',
code_size_95='$code_size_95',
code_size_10='$code_size_10',
code_size_105='$code_size_105',
So the expression would replace everything outside of '$permalink_title' with whitespace. Ideally it would go one better and replace everything with whitespace leaving only the PHP variable - $permalink_title
*Note - I was going to perform this function with Komodo Edit or Notepad++
Any help would be great.
Use this regex :
(^[^']+|(?<=')[^']+$)
Debuggex Demo
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 8 years ago.
Improve this question
I'm outputting database information that contains code such as <b> or <u> or <i> but the text isn't styling. I'm using nlbr() to format it correctly and htmlspecialchars() when inputting textarea text into a database if that helps.
What am I missing?
If the input string passed to this function and the final document share the same character set, this function is sufficient to prepare input for inclusion in most contexts of an HTML document. If, however, the input can represent characters that are not coded in the final document character set and you wish to retain those characters (as numeric or named entities), both this function and htmlentities() (which only encodes substrings that have named entity equivalents) may be insufficient. You may have to use mb_encode_numericentity() instead.
htmlspecialchars — Convert special characters to HTML entities
htmlentities — Convert all applicable characters to HTML entities
http://php.net/manual/en/function.htmlspecialchars.php
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to convert kruti dev (Indian language) to unicode. There is this site - http://rajbhasha.net/drupal514/UniKrutidev+Converter which converts krutidev to unicode but this is done in javascript. I want to do it in php, can someone help.
What you have to do is not an encoding conversion but a custom character mapping.
In an encoding a specific byte or byte sequence stands for a specific character. The font then visualizes this character. For example, in ASCII the byte x41 stands for the character "A", and different fonts have different shapes to display this "A" visibly on screen.
In the case of Kruti Dev, apparently at the time it came into being, there was no encoding for Indian languages; i.e. there was no particular byte specified that should represent "व" in any system in use at the time. What the creators of Kruti Dev did was simply redefine the shape of a letter. The bytes still said the letter was "A", the operating system still thought it was handling the letter "A", but the font contained the shape of "व" for visual display.
So there's no encoding conversion you can do here, since the underlying encoding is being abused in non-standard ways to begin with. What you need to do is to map latin letters to actually specified Indian letters. You need to substitute every "A" for "व" (just an example, no idea about the actual mapping).
Check out iconv
$str = iconv($srcencoding, $destencoding, $str);