0

I want to echo a string but I want to clean it up a little before echoing it from a database as it contains too much information.

I think that I need to use substring and possibly strpos for it.

This is what I have at the moment but I cant seem to figure it out:

implode(
    ';<br>',
    unserialize($row['postvars'])[substr('stuff', 0, strpos('stuff', '('))]
)

So "stuff" is the string I want to echo and it looks something like this:

I want to remove evreything after the first bracket.

zaxzax
  • 75
  • 1
  • 8

3 Answers3

2
echo strstr("Fix kõneside ja/või -interneti (Ärikliendi internet, voip telefonid jne)", '(', true);
vitaliytv
  • 487
  • 5
  • 8
0

you cat use a regular expression

$string ="Fix kõneside ja/või -interneti (Ärikliendi internet, voip telefonid jne)";
$output = preg_replace( '/(?=\().*/', '', $string );

echo $output;

regular_expressions in php

pedram shabani
  • 1,614
  • 2
  • 19
  • 28
0
$pos = strpos($teenused, '(');
$n = strlen($teenused) - $pos;
$rest = substr("$teenused", 0, -$n);