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 806 views
–1 vote
0 answers 171 views
+2 votes
3 answers 328 views
asked in Programming by jatin Expert (3,823 points)
+3 votes
1 answer 861 views
+2 votes
2 answers 828 views
+2 votes
1 answer 1,036 views
+6 votes
2 answers 3,191 views
+1 vote
1 answer 131 views
+1 vote
1 answer 180 views

Not a Member yet?

Ask to Folks Login

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