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 (380 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

+4 votes
5 answers 771 views
–1 vote
0 answers 153 views
+2 votes
3 answers 315 views
asked in Programming by jatin Expert (3,823 points)
+3 votes
1 answer 814 views
+2 votes
2 answers 810 views
+2 votes
1 answer 868 views
+6 votes
2 answers 2,972 views
+1 vote
1 answer 123 views
+1 vote
1 answer 175 views

Not a Member yet?

Ask to Folks Login

My Account
453 Folks are online
1 members and 452 guest online
Your feedback is highly appreciated