Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

compare strings alphabetically php

Use strcmp.
If the first argument to strcmp is lexicographically smaller to the second, then the value returned will be negative.
If both are equal, then it will return 0.
And if the first is lexicograpically greater than the second then a positive number will be returned.

Bonus fact: You probably want to use strcasecmp(string1,string2), which ignores case.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #compare #strings #alphabetically #php
ADD COMMENT
Topic
Name
1+1 =