Random PHP code needed

3 replies
I am looking to put a code on my WP blog that will pull in 2 files, having a hard time finding one searching in google...

The first file I want it to pull from a list of keywords - or better yet - a list of spinable keywords making them longtail if possible, the second file I want it to pull from a list of URLs so it makes spun internal backlinks with my keywords

I have one, but it only pulls from 1 file and I do not want to manually enter in all the URLs and keyword combos

<?php

$fcontents = join ('', file ('randomlinks.php'));
$s_con = split("~",$fcontents);

$link_no = rand(0,(count($s_con)-1));
echo $s_con[$link_no];
?>

any help would be great as this code pulls from the randomlinks.php and it has to be formatted like this:

<a href="mylink">keyword</a>
~
<a href="mylink">keyword</a>
~
<a href="mylink">keyword</a>

If I could make it pull from a second file inside randomlinks, that is what I am looking for...

<a href="mylink">getkeywords.php</a>

and format it exactly like the other file

KEYWORD1
~
KEYWORD2
~
ECT...
#code #needed #php #random
  • Profile picture of the author slamriot
    I found a work around, but still having trouble, I downloaded a plugin that allows me to spin content on my blog, so now, I can simply use this in my template


    <a href="???">{keyword|keyword|keyword}</a>

    The only problem now is I want to pull a random link from either a .php or .txt file

    Can anyone help? I know there is a simple solution to this, just cannot find it through all the garbage on google search
    {{ DiscussionBoard.errors[3330643].message }}
    • Profile picture of the author JohnyData
      I wrote a very simple php script that I use for my 404 pages.

      What happens is when someone is supposed to see my 404 page, which is 404.php, the coding within the 404.php file then sends them to a random page within my site (used mainly for split-testing and whatnot).

      I could modify the code a bit so that you could link to the 1 file, say link.php, and essentially, it would work as follows:

      Your current code would be set to <a href="link.php">{keyword|keyword|keyword}</a> and when the user clicks on it, they are taken to links.php which then redirects them to a random link within the link list.

      Would something like that work for you?
      {{ DiscussionBoard.errors[3331082].message }}
      • Profile picture of the author slamriot
        I figured it out using an include function, thanks tho
        {{ DiscussionBoard.errors[3339033].message }}

Trending Topics