Jump to content

replacing string without removing brackets


DiavolO

Recommended Posts

First of all, I want to apologise for my incorrect english language :)

Secondly with php i'm 'not very newbie', but there is enough space to improve...

Also, I have problem with regular expresions:

I have a string which is formed like:

any word/(-s) ( any word/(-s) )

or

any word/(-s) ( any word/(-s) ) ( any word/(-s) )

 

just like:

Information (Technologies)

or

Speciality (Information Technologies) (High Grade)

 

what i need is to shorten it with only first letters of each word, like:

I (T)

or

S (IT) (HG)

 

leaving all the brackets.

Also, i have already managed with some code, which is not working correctly:

 

$test3 = str_replace(" and ", " ", $subcat5); //replacing 'and' with space
$test4 = explode(' ',$test3); 
foreach($test4 as $v){$test5.=substr($v,0,1);}
$spec_trump = strtoupper($test5); //if needed

so if string is: Speciality (Information Technologies) (High Grade)

result will be: S(T(G

what i need is: S (IT) (HG)

 

 

Can anyone help me out, with this stuff?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.