Hey there! any question in your mind? Ask It Now!.

Popular Categories

How to remove a specific string from array in PHP?

+2 votes
asked in Programming by nishant (420 points)
retagged by Bhartesh

I have an array in which links and titles  are stored like this :

$array = array();

foreach($books as $img) 

$array[$title] = $src;


Now in title some unwanted characters are coming i want to remove  replace those characters from array.Thanks for help!

1 Answer

+1 vote
answered by nitin (810 points)

There is a simple function for the same see:

lets say you want to remove asdf from a string $title  which is

$title = “Appleasdf ” ;

str_replace('asdf','', $title)

Here we have replaced asdf from blank so now your string is

$title = “Apple”;

I hope you would use this according to your need.

Related Questions

–1 vote
0 answers 192 views
+2 votes
3 answers 362 views
+3 votes
1 answer 912 views
+2 votes
1 answer 1,289 views
+6 votes
2 answers 3,554 views
+1 vote
1 answer 161 views

Not a Member yet?

Ask to Folks Login

My Account
325 Folks are online
0 members and 325 guest online
Your feedback is highly appreciated