0

i've a string

$string;

in this string i have a number, like 3743687

i wish to add a slash after every number, except at the end, so the result will be

3/7/4/3/6/8/7

is there a php function to do this, right ? any advice ? thanks

CalfCrusher
  • 350
  • 1
  • 4
  • 15

2 Answers2

4
$string = '3743687';

$newString = implode('/',str_split($string));

var_dump($newString);
Mark Baker
  • 209,507
  • 32
  • 346
  • 385
1
$string = "3743687";

$string = implode("/", str_split($string));

echo $string;
SubjectCurio
  • 4,702
  • 3
  • 32
  • 46