I have the following data listing of a WHILE
in PHP
<?php
$query = "SELECT * FROM table where value='$thisvalue'";
$result = mysqli_query($conexion, $query);
while ($row = mysqli_fetch_assoc($result)) {
$campo = $row['value'];
//QUITAR PALABRAS SI ENCUENTRA UN - SOLO PALABRAS.
echo $campo;
}
PANELEGP00001
PANELEGP00003
PANELEGP00001-1
PANELEGP00002-TOS
PANELEGP00004-2
LIVOR-44_900_2100
I want to be able to remove the words JUST THE WORDS when I find a - . I have searched for methods in PHP, tried with str_replace
but I have not had results.
I would like such a result.
PANELEGP00001
PANELEGP00003
PANELEGP00001-1
PANELEGP00002 //SE QUITO LA PALABRA TOS
PANELEGP00004-2
LIVOR-44_900_2100
You can use
explode
andis_numeric
like this:I think for this it is best to use preg_replace ( http://php.net/manual/en/function.preg-replace.php ) with a regular expression. For example, to search for the text you say, on the line that says
you should put
Luck!