hi,
i'm developing this small seo component, i want to know how it should be done. now i'm writing seo meta tags and other tags search engines looking into the page. i'm getting the content of the page and look for the previous set of say, keywords and replacing them with the new set. and same for the other tag, but i have a problem here. if the page contains same text in another place , it will be replaced too. hope you can give me a solution for this. thanks in advance.

You need to give your code unless you're using str_replace.

If you are using str_replace, since meta tags are above everything else, you can make use of the optional count parameter as per manual:
mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

Member Avatar for diafol

No idea what you need. Print your code and highlight the areas that your need sorted. In general - ensure that you have a querystring or htaccess rewrite equivalent for SEO.

You need to give your code unless you're using str_replace.

If you are using str_replace, since meta tags are above everything else, you can make use of the optional count parameter as per manual:
mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

hi , most of the times its <link> tags, since in need them too

$replace1=str_replace('href="'.$arr['nextpagehid'].'"','href="'.$arr['nextpage'].'"',$replace1);
$replace1=str_replace('href=\''.$arr['nextpagehid'].'\'','href=\''.$arr['nextpage'].'\'',$replace1);

if i do it as you say, do i have to replace in an array and array count parameter equal to one? can you please explain it a bit further?

No idea what you need. Print your code and highlight the areas that your need sorted. In general - ensure that you have a querystring or htaccess rewrite equivalent for SEO.

please see my reply for the code.

No. Just replace

$replace1=str_replace('href="'.$arr['nextpagehid'].'"','href="'.$arr['nextpage'].'"',$replace1);
$replace1=str_replace('href=\''.$arr['nextpagehid'].'\'','href=\''.$arr['nextpage'].'\'',$replace1);

with

$replace1=str_replace('href="'.$arr['nextpagehid'].'"','href="'.$arr['nextpage'].'"',$replace1,1);
$replace1=str_replace('href=\''.$arr['nextpagehid'].'\'','href=\''.$arr['nextpage'].'\'',$replace1,1);

No. Just replace

$replace1=str_replace('href="'.$arr['nextpagehid'].'"','href="'.$arr['nextpage'].'"',$replace1);
$replace1=str_replace('href=\''.$arr['nextpagehid'].'\'','href=\''.$arr['nextpage'].'\'',$replace1);

with

$replace1=str_replace('href="'.$arr['nextpagehid'].'"','href="'.$arr['nextpage'].'"',$replace1,1);
$replace1=str_replace('href=\''.$arr['nextpagehid'].'\'','href=\''.$arr['nextpage'].'\'',$replace1,1);

oo hou, had no idea that str_replace has another parameter, thanks a lot tiggsy..!!!

hey i got this error <b>Fatal error</b>: Only variables can be passed by reference in

ok. paste in your code on the lines that it says the error is

ok. paste in your code on the lines that it says the error is

i found out , that 4th parameter is an out parameter..
i can use preg_replace to limit it that way. am i right?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.