Lis yo chin
Lis yo chin

Reputation: 13

Laravel string replace item

How to i replace '[' charachter to span class = "someclass" .I wrote this code but it gives me only text

$replaced = str_replace(
            array('[', ']'),
            array("<span class"."='innovation_color innovation_color-services".">","</"."span".">"),
             $string
        );

Upvotes: 0

Views: 144

Answers (1)

Mathieu Ferre
Mathieu Ferre

Reputation: 4412

you are missing some quotes :

$replaced = str_replace(
            ['[', ']'],
           ["<span class"."='innovation_color innovation_color-services'".">","</"."span".">",
             $string
        );

Upvotes: 1

Related Questions