At regex 101, you will no longer have problems of figuring out how they work or test how it works. I have come across this little beauty https://regex101.com/ . All you have to do is, have a copy of the text you… Continue Reading →
I came across a small issue to display the singular version of any English word using some grammar rules to de-pluralise a word.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
function depluralize($word){ // Here is the list of rules. To add a scenario, // Add the plural ending as the key and the singular // ending as the value for that key. This could be // turned into a preg_replace and probably will be // eventually, but for now, this is what it is. // // Note: The first rule has a value of false since // we don't want to mess with words that end with // double 's'. We normally wouldn't have to create // rules for words we don't want to mess with, but // the last rule (s) would catch double (ss) words // if we didn't stop before it got to that rule. $rules = array( 'ss' => false, 'os' => 'o', 'ies' => 'y', 'xes' => 'x', 'oes' => 'o', 'ies' => 'y', 'ves' => 'f', 's' => ''); // Loop through all the rules and do the replacement. foreach(array_keys($rules) as $key){ // If the end of the word doesn't match the key, // it's not a candidate for replacement. Move on // to the next plural ending. if(substr($word, (strlen($key) * -1)) != $key) continue; // If the value of the key is false, stop looping // and return the original version of the word. if($key === false) return $word; // We've made it this far, so we can do the // replacement. return substr($word, 0, strlen($word) - strlen($key)) . $rules[$key]; } return $word; } |
I can’t claim that this was my work, but here is the authors link where I… Continue Reading →
I love Advanced Custom Fields (AFC) advancedcustomfields.com. Recently I came across a small problem. I had to attach the a user photo, using
1 |
image |
type from the ACF. I created the signup form with a
1 |
file |
type
1 |
<input type="file" name="user_photo" > |
But the… Continue Reading →
Most often I come across the same problem. When users search the pages, they have a problem! The problem How to search custom fields as well as content and title etc on wordpress and display them. The solution It’s really… Continue Reading →
Ever wondered how to get the label of your multiple choice fields on advanced custom fields for your front end? Often I come across using get_field(‘{field_name}’) however this just returns the value of the Select field type, or radio or… Continue Reading →
© 2018 JQUI Net — Powered by WordPress
Theme by Anders Noren — Up ↑