-7

$string = "comment-454";

I want to disply only 454? not comment-

i am saving in db comment-454 , now i want to crop comment-.. how can i

can someone provide me something, because i am newbie in php.. thanks in advance..

XeanNeia
  • 13
  • 1
  • 5

2 Answers2

1

$string = str_replace("comment-", "", "comment-454");

should replace what you want.

you mentioned comment-454 came from your database. So ill assume it's in $result.

Now you can do:

$string = str_replace("comment-", "", $result);

echo $string;
Déjà vu
  • 774
  • 2
  • 9
  • 31
0

Use explote() http://php.net/manual/de/function.explode.php

$teile = explode("-", $string); echo $teile[1]; // 454

Weexe
  • 140
  • 12