chris227 chris227 - 2 months ago 6
PHP Question

Select names from a string using php

Hello I have the following string and I want to keep only what is after

:

here is my string :

/showname/88820665 : Jysk diner
/showname/88820666 : Sevecu
/showname/88820667 : Luminex Lightcares
/showname/88820668 : Pactius
/showname/88820669 : Aalborg Speciallaegeklinik

Answer

You can use explode()

 $pieces = explode(":", $myString);

 echo $pieces[1];  // should contain  the right part of the string after :

In you have a single row string then

  $myRows= explode("\n", $myString);

  foreach( $myRows as $key => $value) {
    $pieces = explode(":", $value);
    echo $pieces[1]; 
  }
Comments