[Solved] Please How can i extract all the words after each = from this string “SHORT.NAME:1=Niger,SHORT.NAME:2=Daniel,SHORT.NAME:3=GLORIA,”


This code will “extract” and print to the screen the words between each equal sign and the following comma:

$str = "SHORT.NAME:1=Niger,SHORT.NAME:2=Daniel,SHORT.NAME:3=GLORIA,";

$arr = explode( ',', $str );

$shortNames = array();
foreach ( $arr AS $element ) {
  $shortNames[] = explode( '=', $element );
}

foreach ( $shortNames AS $shortName ) {
  if ( isset( $shortName[ 1 ] ) ) {
    echo $shortName[ 1 ] . '<br>';  // replace this line
  }
}

You can replace echo $shortName[ 1 ] . '<br>'; with whatever you actually want to do with the words.

3

solved Please How can i extract all the words after each = from this string “SHORT.NAME:1=Niger,SHORT.NAME:2=Daniel,SHORT.NAME:3=GLORIA,”