Title: Basic PHP Question
Last modified: August 18, 2016

---

# Basic PHP Question

 *  [barbarac](https://wordpress.org/support/users/barbarac/)
 * (@barbarac)
 * [21 years ago](https://wordpress.org/support/topic/basic-php-question/)
 * Hi,
 * I am trying to pass the value of “the_permalink();” in my index.php file into
   a split function but cannot seem to get the results that I need.
 * Basically I want to use everything after “=” in another function.
 * What am I doing wrong?
 * <?php
    $testLink = the_permalink(); echo $testLink; $query = split( “=”, ($testlink));
   $number = $query[1]; echo $number; ?>

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [ifelse](https://wordpress.org/support/users/ifelse/)
 * (@ifelse)
 * [21 years ago](https://wordpress.org/support/topic/basic-php-question/#post-183850)
 * 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.
 *  Thread Starter [barbarac](https://wordpress.org/support/users/barbarac/)
 * (@barbarac)
 * [21 years ago](https://wordpress.org/support/topic/basic-php-question/#post-183851)
 * 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/](http://www.cafegeek.com/home/)
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years ago](https://wordpress.org/support/topic/basic-php-question/#post-183852)
 * Use `get_permalink()` to return the permalink as a value to assign to your $testLink
   var.
 *  [ifelse](https://wordpress.org/support/users/ifelse/)
 * (@ifelse)
 * [21 years ago](https://wordpress.org/support/topic/basic-php-question/#post-183854)
 * the_permalink echoes the permalink url. I think what you’ll need is get_permalink()
 *  [ifelse](https://wordpress.org/support/users/ifelse/)
 * (@ifelse)
 * [21 years ago](https://wordpress.org/support/topic/basic-php-question/#post-183855)
 * Kafkaesqui got there first… should have clicked refresh before posting:-)
 *  Thread Starter [barbarac](https://wordpress.org/support/users/barbarac/)
 * (@barbarac)
 * [21 years ago](https://wordpress.org/support/topic/basic-php-question/#post-183859)
 * 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/](http://www.phpsoft.org/).

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Basic PHP Question’ is closed to new replies.

 * 6 replies
 * 3 participants
 * Last reply from: [barbarac](https://wordpress.org/support/users/barbarac/)
 * Last activity: [21 years ago](https://wordpress.org/support/topic/basic-php-question/#post-183859)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
