legohead6 Posted August 1, 2006 Share Posted August 1, 2006 how i cannot find a function! i want to cut these letters out then put them into another string in the order the were cut!EDIT: by "these" i mean like an array of lettersor how to find all letters that were changed by str_replace... Quote Link to comment Share on other sites More sharing options...
trq Posted August 1, 2006 Share Posted August 1, 2006 Your not being very clear. Maybe your looking for [url=http://php.net/substr]substr[/url](), but really... who knows. Quote Link to comment Share on other sites More sharing options...
legohead6 Posted August 1, 2006 Author Share Posted August 1, 2006 k i have an array or letters..(lets say $letters) and i have a sentence (say $text) I want to have it go through the sentance and find all the letters in the $letter array and remove them from the sentance. Then make them into there own array(called $removedletters) Quote Link to comment Share on other sites More sharing options...
trq Posted August 1, 2006 Share Posted August 1, 2006 Probably better ways around, but....[code=php:0]<?php $letters = array('a','b','c','d'); $text = "this is a big bad string"; foreach($letters as $letter) { if (strpos($text,$letter)) { $removedletters[] = $letter; $text = str_replace($letter,"",$text); } } echo "the letters ".implode(" ",$removedletters)." were removed from '$text'";?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.