split is really the wrong function to use in this instance. Split breaks up a string into array. What you are asking for is the substring of everything after your delimiter ‘=’.
First you’ll need to find the position of the delimiter.
$pos = strpos($testLink,'=');
Now, using this offset, we can get everything after it.
$number = substr($testLink, $pos);
However, whilst this is what you asked for, this may not be what you are looking for. This may, on ocaasions, get you a load of unrelated info e.g. if the reader does a search.
You can get what you want with the following:
$number= $_GET['p'];
This will allow you to get the value of the get variable p that is passed in the query string.
Thanks ifelse,
However on the page that I am using I am not getting the permalink form the URL but from the “the_permalink();”
Here is how I’ve implemented what you suggested
<br>**********************************<br>
<?php
$testLink = the_permalink();
$pos = strpos($testLink,’=’);
$number = substr($testLink, $pos);
echo $number;
?>
<br>**********************************<br><br>
and here is how its parsing
http://www.cafegeek.com/home/
Use get_permalink() to return the permalink as a value to assign to your $testLink var.
the_permalink echoes the permalink url. I think what you’ll need is get_permalink()
Kafkaesqui got there first… should have clicked refresh before posting:-)
Awesome. Thanks to all for the help!!
Here is the final code for reference:
<?php
$testLink = get_permalink() ;
$query = split( “=”, $testLink);
$number = $query[1];
echo rate($number);
?>
You’ll note that I have passed the data into the great ratings function from http://www.phpsoft.org/.