Last Word Of String UpperCase?

I try to accomplish the following.I have a string like: “volkswagen-golf-gti” **

And I want it to change the string into: “Volkswagen Golf GTI” (last part completely uppercase)

But I have some difficulties understanding preg_replace.

Right now I have the following code:
$string = 'volkswagen-golf-gti'; 
$string2 = ucwords(str_replace('-', ' ', $string)); 
$string2 = preg_replace("/s+S+$/e", "strtoupper('\1')", $string2); 
echo $string2; 


How can I change the code so it select the last part of $string2 and makes that part uppercase? So the result of echo $string2; will be: Volkswagen Golf GTI ** $string can be anything, not only volkswagen-golf-gti


Ucwords(): Uppercase The First Character Of Each Word In A String Accept 'and', 'to', Etc?

How can I make upper-case the first character of each word in a string accept a couple of words which I don't want to transform them, like - and, to, etc?For instance, I want this - ucwords('art and design') to output the string below,'Art and Design'is it possible to be like - strip_tags($text, '<p><a>') which we allow and in the string?or I should use something else? please advise!

View 3 Replies View Related

First Letter Of A Word In Uppercase

How can I make sure in php that a word always starts with an uppercase? Let's say I've got a parameter $word holding the word 'wordlowercase' and I want it to be 'Wordlowercase'.

View 1 Replies View Related

Keep Some Of Word Be Uppercase On Ucwords?

Example in my database SMK SUNGAI PUNAI

$school = 'SMK SUNGAI PUNAI';
echo ucwords(strtolower($school));
Ouput Smk Sungai Punai

QuestionHow to make the output will be SMK Sungai Punai which the SMK still in uppercase.Update.The problem I have 10K list of school name. From PDF I converted to mysql. I copied exactly from PDF the name of schools. All in uppercase. I need a solution if can be done.

View 3 Replies View Related

Make The First Character Of The Word Uppercase?

Do you know is there any function in PHP to make the first character of the word uppercase? Or must I write it by regular expression?

View 4 Replies View Related

Create The Uppercase MD5 Value Of The ASCII Equivalent Of A Word?

I have a secret word (example. dirtydawg) And using PHP I want to create the uppercase MD5 value of the ASCII equivalent of the secret word. How do I do this?

View 3 Replies View Related

Replace Words Of A String Maintain Lowercase And Uppercase Chars Of Original String?

I have, for example, this string $string='Hello World, hello world'; I have a parameter in lowercase or uppercase and I need to replace all the equal words for <stong>word</strong> If i try this:


The result are Hello world, hello world (lowercase w in the first word) is to be possible replace string maintain lowercase and uppercase of the original string?

View 1 Replies View Related

String With Uppercase

I'm looking for a string function that will allow me to take a string with uppercase and lower case letters and add a space before the uppercase letters, e.g. "LeeHarveyOswald" becomes " Lee Harvey Oswald".

View 3 Replies View Related

Determine If String Is All Uppercase?

Is there a simple way to determine if a string is all in uppercase

View 5 Replies View Related

Check If At Least 75% Of A String Is UPPERCASE?

I'm writing bug tracking software in PHP, and today I saw this in another bug tracker: I want to add a feature in my software which will block titles where at least 75% of all characters is uppercase.P.S. CSS will not work, because, for example if you have the word 'iPod' in your title it turns into 'ipod' which sucks

View 1 Replies View Related

Get The Position Of An Uppercase Character In A String

Does anybody know how I can get the position of an uppercase character in a string?
For example, lets say I want to find the position of the second Uppercase character in the string: "HelloThere", which is the "T".

View 2 Replies View Related

String - Mb_convert_case() Keep Words That Are In Uppercase?

Assuming I have a string "HET1200 text string" and I need it to change to "HET1200 Text String". Encoding would be UTF-8.

How can I do that? Currently, I use mb_convert_case($string, MB_CASE_TITLE, "UTF-8"); but that changes "HET1200" to "Het1200.

I could specify an exception, but it won't be an exhaustive. So I rather all uppercase words to remain uppercase.

View 2 Replies View Related

Count Uppercase Words In String

is there an easy way to count uppercase words within a string?

View 5 Replies View Related

Regex - Detect If String Contains 1 Uppercase Letter

I'm assuming I need to use regex? I'm trying to do html redirects in php in cases where the url contains at least 1 upper case letter. example: [URL] needs to be redirected to [URL] - only problem is I can't seem to find a script to detect if at least 1 capital letter exists.

View 2 Replies View Related

String Transform First Character Uppercase / Lowercase

I have two types of strings, 'hello', 'helloThere'. What I want is to change them so they read like: 'Hello', 'Hello There' depending on the case.

View 6 Replies View Related

Convert String To Uppercase But Not Html Markup?

Im a bit stumped on how to make a string uppercase in php while not making the markup uppercase.So for example:

<p>Chicken &amp; <a href="/cheese">cheese</a></p>
Will become
<p>CHICKEN &amp; <a href="/cheese">CHEESE</a></p>

View 4 Replies View Related

Check If A String Has Only Lowercase / Uppercase Letters?

How do check if a string has only lowercase/uppercase letters and has at least one number in it?

View 3 Replies View Related

Make All The Words In A String With 3 Characters Or Less Completely Uppercase?

I trying to accomplish the following:

$string = "i want to convert this string to the following";

and convert it to something like this:

echo $string;
// I Want TO Convert This String TO THE Following

Thus: Capitalize the First Letter of All Words in a string and if a word is 3 characters or less, make the whole word Capitalized in the string. How cant this be done with PHP?

View 2 Replies View Related

Preg_match Make Sure First Character In String Is Uppercase Or Lowercase Letter?

can someone show me the regex for this preg_match. I want to make sure first letter in string is nothing but a letter, either uppercase or lowercase. I found this, but it doesnt seem to be working.

var_dump(preg_match("^/[A-Za-z]+/", $search_terms )); The line above returns false, every time.

View 2 Replies View Related

Find A Word In A File - Make The Line That The Word Came From Into A String?

I want to find a word in a large list file. Then, if and when that word is found, take the whole line of the list file that the word was found in? so far I have not seen any PHP string functions to do this

View 4 Replies View Related

Find Part Of A Word And Then Replace The Whole Word With A String?

so if i have the text: "this is going to be really great" and i have the needle "goi"

i want it to find going and then replace it with the link[URL]...

View 3 Replies View Related

Remove Entire Word If The Word Contains Specific String?

I would like to do the following, preferably with PHP:

Remove an entire word if a part of the word contains a specific string. This should be case insensitive and work multiple times, e.g. on a large text.

match = "www."
lots_of_random_text = "... hello and welcome to! blah blah"
result = magic_function(lots_of_random_text, "www.")

result should now equal to: "... hello and welcome to blah blah".

How would I do this the most efficient way?

View 1 Replies View Related

Str_replace() - Remove A Word If It's Exactly The Word In String

I'm cleaning a string removing strings in this array:

$regex = array("subida", " de"," do", " da", "em", " na", " no", "blitz");

And this is the str_replace i'm using:

$twit = str_replace($regex[$i],'', $twit);

how do I make it only remove a word if it's exactly the word in string, I mean, I have the following phrase: "#blitz na subida do alfabarra blitz" it will return me: "# alfabarra", I don't want the first "blitz" to be removed because it has a hash "#", i want it to output: "#blitz alfabarra", is it possible?

View 2 Replies View Related

Attaching A String To A Normal Word Without Loosing The String

In my database I have content rows that are either called <contentname>_title or <contentname>_fulltext. now when someone clicks a link on the site it goes to index.php?action=<contentname> so I guess you see where im going..

when someone goes to such a section index.php sees $action is used and attaches it to _title and _fulltext, so u get: $action_fulltext.. basicly of cuz php now sees it as one string '$action_fulltext' and not '$action'_fulltext.

View 3 Replies View Related

Search String For Word If Not Found Search Another Word?

I would like to search a string for a word and if this word is not found I'd like it to search for another word and keep going until it find one I have seen codes to search a string but not to keep searching.

View 4 Replies View Related

Whole Word In String

As a newbie to PHP, can someone please help me with a frustrating small problem that has defeated my searches of the PHP manual. I want to search a string of text for the occurrence of a certain word or set of words. Easy enough, but I only want to find occurences of whole words. For example, if I'm searching for "today's exam", I want to ignore "today's example".

View 1 Replies View Related

Word In A String

I'm trying to check if a specific word exists in a specific string. For that I'm using strpos function, like this:

if (strpos($str, $word)==0) // do something

But this statement returns true also when $word is the first word in $str.

View 2 Replies View Related

Get Certain Word From String?

If i have a string like this:

$myString = "input/name/something";

How can i get the name to be echoed? Every string looks like that except that name and something could be different.

View 4 Replies View Related

Searching For A Whole Word In The String?

I'd like to be able to do the following.Lets say i have a string:
$found=" Justin is in the house ";

How would i go about searching for a whole word in the string?
For example: I want to find the word "in"

if i say :
eregi("in",$found), it will find me not only the word "in" but also the word "Justin" because it contains "in" .

How do i make it search for a whole word only?
Bear in mind that when i say ' a word ' i dont necessarily mean the word "in" but any word in general.

View 4 Replies View Related

Remove Word From String

I got this function from somewhere else:

$var = "somesomesome and in somesomei I somie, some. someone .some";
$badword = "some";
$var = preg_replace(array("/([W]+){$badword}([W]+)/","/([W]+){$badword}([W]+)/"),$1?.str_repeat("*",strlen($badword)).$2?,$var);

This is to remove word from a string but that word SHOULD not be a part of any word. for example if i want to remove "some" then "someone" should be left as it is. BUT this function is not working properly.

View 1 Replies View Related

String - How To Get First Word Of A Sentence

i want only the first word of a variable.. example input:

<?php $myvalue = 'Test me more'; ?>

the output should only "Test", the first word of the input.. how can i do this?

View 11 Replies View Related

Copyrights 2005-15, All rights reserved