Hello Bob, again I say, thanks so much, I was able to incorporate
(with a few tweaks) your code into my code, the lines to remove the
extra words, I had to add _ before and after each word otherwise it
removed all instances of those letters, even if they were part of
another word, ("toward" became "ward"), adding the underscores
isolated the words I wanted removed without altering any other words.
The next one "accept only a to z + spcs" worked too well, it removed
everything (but the letters) including the .html part and the
underscores between all the words, so I just omitted it. Instead I
did this:
$remove = array
('_to_','the_','_the_','_it_','_and_','_or_','_with_','_too_','_also_
','_an_','_if_','_at_','_a_','_i_','_in_','_for_','_of_','__','___','
____','_-_');
$filename=str_replace($remove,"_",$filename);
$remove = array
('?','!','%','&','(',')','"','@','/','$',',',';',':','*','#','"','"',
'=','+','-');
$filename=str_replace($remove,"",$filename);
That works great, the only character I can't put into the line to be
removed or replaced is ' it makes an error if I put that in, if
there is a way to include that in the line, it would be great, any
suggestions?
I didn't really need the rest of it, I don't get extra spaces, the
code already adds .html and I fixed the part that trims the file
name to a certain size.
This is so close to perfect for me, thanks, thanks, thanks everyone!
Wretha
--- In [email protected], "Bob" <[EMAIL PROTECTED]> wrote:
>
> Hi Wretha,
> Here's some ideas:
>
> <?php
> $title = "Hello <123> #*&%$£! to, the, it, and, or, with, too,
also, a, if, Wretha";
>
> // all lowercase
> $filename=strtolower($title);
>
> // uncomment next 2 lines to see what it does
> // $remove = array
('to','the','it','and','or','with','too','also','an','if');
> // $filename=str_replace($remove,"",$filename);
>
> // accept only a to z + spcs
> $filename=preg_replace("/[^a-z ]/","",$filename);
>
> // 1 or more spcs to underscore
> $filename=preg_replace("/[ ]+/ ","_",$filename);
>
> // cut filename to length
> $filename=substr($filename,0,20);
>
> // trim and add file extension
> $filename=trim($filename).".html";
>
> echo $filename;
> ?>
>
> To get rid of small words, I'd probably look for words <= 3 chars
and delete them.
> Maybe someone has a better solution?
> Bob E.
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/