Jump to content

Recommended Posts

First off i know im a noob at this stuff but have been searching for 2 days and this is a last resort before hiring someone.

 

i need help with a str_replace expression and a rewrite.

 

str_replace expression.

what i need to do is replace 26 different items and have it write them differently. this is going to be called in 2 spots on my site. 1 is in the title tag and the other is in the page its self.

 

here is the 26 str_replace statements. i already know i did it totally wrong.

 

//$typename = str_replace("dailyteenhoroscopes", "Daily Teen", "$type");

//$typename = str_replace("dailyoverview", "Daily Overview", "$type");

//$typename = str_replace("dailyextended", "Daily Extended", "$type");

//$typename = str_replace("dailysingleslove", "Daily Singles Love", "$type");

//$typename = str_replace("dailycoupleslove", "Daily Couples Love", "$type");

//$typename = str_replace("dailyflirt", "Daily Flirt", "$type");

//$typename = str_replace("dailywork", "Daily Work", "$type");

//$typename = str_replace("dailyquickie", "Daily Quickie", "$type");

//$typename = str_replace("dailygreenscope", "Daily GreenScope", "$type");

//$typename = str_replace("dailybeautyscope", "Daily BeautyScope", "$type");

//$typename = str_replace("dailyastroslam", "Daily AstroSlam", "$type");

//$typename = str_replace("dailybabyscope", "Daily BabyScope", "$type");

//$typename = str_replace("dailycatscope", "Daily CatScope", "$type");

//$typename = str_replace("dailydogscope", "Daily DogScope", "$type");

//$typename = str_replace("dailyhomeandgarden", "Daily Home and Garden", "$type");

//$typename = str_replace("dailygayscope", "Daily GayScope", "$type");

//$typename = str_replace("dailylesbianscope", "Daily LesbianScope", "$type");

//$typename = str_replace("dailychinese", "Daily Chinese", "$type");

//$typename = str_replace("weeklybusiness", "Weekly Business", "$type");

//$typename = str_replace("weeklyoverview", "Weekly Overview", "$type");

//$typename = str_replace("weeklytravel", "Weekly Travel", "$type");

//$typename = str_replace("weeklyflirt", "Weekly Flirt", "$type");

//$typename = str_replace("weeklyromantic", "Weekly Romantic", "$type");

//$typename = str_replace("monthlyoverview", "Monthly Overview", "$type");

//$typename = str_replace("monthlyfitness", "Monthly Fitness", "$type");

//$typename = str_replace("monthlycareer", "Monthly Career", "$type");

//$typename = str_replace("monthlyromantic", "Monthly Romantic", "$type");

 

 

 

2nd problem htaccess rewrite

 

i need to make this url into a seo url

 

these are the urls i have now on the site. there are 312 different ones. they all follow this format.

index.php?sign=Aries&type=dailyoverview&p=1

index.php?sign=Libra&type=dailyteenhoroscopes&p=1

 

into

 

domain.com/Aries/dailyoverview/1

or

domain.com/sign/Libra/type/dailyteenhoroscope/p/1

 

what ever one is better.

 

If someone can help it would be great.

 

Thank you in advance.

Link to comment
https://forums.phpfreaks.com/topic/90021-solved-need-help-with-2-items/
Share on other sites

You don't say WHAT is not working with yur str_replace functions, but I will take a guess.

1) They are all commented out.

2) The first line will replace the first value in the $type variable and assign that result to $typename. however the next line will replace the 2nd value IN THE ORIGINAL $type variable (in other words you just lost the replacement on the first line). This continues all the way to the end, so only the last replacement is done.

3) This won't keep it from working, but there's no need to enclose $type in quotes.

 

however, there is a much easier way to do this by using arrays:

 

<?php

$codes = array('dailyteenhoroscopes', 'dailyoverview', 'dailyextended', 'dailysingleslove');
$texts = array ('Daily Teen', 'Daily Overview', 'Daily Extended', 'Daily Singles Love');
//I only included four sets, just add all of the strings to these arrays

$typename = str_replace($codes, $texts, $type);

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.