php - Print only part of values or to a specific character -


i have in mysql table column "class" , in items :

  • ds1 (1 koera toukerattavedu al.14 a.)
  • dck1 (koerakross, lapsed 6-9)
  • dbw (jalgrattavedu, naised al.16 a.)
  • dr4 (3-4 koera käruvedu, al.16 a.)
  • dr6 (4-6 koera käruvedu al. 16 a.)
  • dck2 (koerakross, lapsed10-13 a.) etc..

with print '<td>' .$row["klass"].'</td>'; prints whole text. can print somehow until "(" ?

to display :

  • ds1
  • dck1
  • dbw
  • etc...

you use preg_replace remove entire paranthesis :

function removeparanthesis($text) {     return preg_replace('/\s*\([^)]*\)/', '', $text); }  print '<td>'.removeparanthesis($row["klass"]).'</td>'; 

would give desired output.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -