Forum Moderators: coopster
loans
home loans
car loans
.
.
i want the script to output the list in the following format
loans, loans.php
home loans, home-loans.php
car loans, car-loans.php
i tried using javascript but i cant get to input the - in the files.
this should be easy for any php guru here.
i would appreciate any help.
<?php
$list = array('loans', 'home loans', 'car loans');
foreach ($list as $value) {
print $value . ', ' . preg_replace("/\s+/", '-', $value) . '.php<br />';
}
?>
<textarea name="keywords" rows="6" wrap="off"></textarea>
Paste your list of keywords into the textarea. Post the form to your script. Access the form field and split the different keywords into array elements using:
$list = explode("\r\n", $_POST['keywords']);
Use $list in Coopster's function. :)
If you don't need fancy replacing rules, you should always use this function instead of ereg_replace() or preg_replace().
so...
str_replace(" ", "-", $value);
Tom
print str_replace(" ", "-", 'car loan'); // prints car-loan
print str_replace(" ", "-", 'car loan'); // prints car--loan