I am creating a custom wordpress theme and i am little stuck in one situation. I created an array $ark and get some values in it

<?php  $ark[] = esc_url( add_query_arg( 'pdff', $post->ID ) );  print_r($ark) ; echo 'jonty'; ?>

here below is the output of the above code;

Array ( [0] => /jobifylocal/wp-admin/admin-ajax.php?pdff=127 ) jonty

what i want is that the only value of pdff after equals-to like here 127 i only need 127 in a $variable to echo somewhere else.

1 Answer 1


Use below code to get the 'pdff' value:

$url_components = parse_url($ark[0]); 

// Use parse_str() function to parse the 
// string passed via URL 
parse_str($url_components['query'], $params); 
// Display result 
echo $params['pdff'];

Not the answer you're looking for? Browse other questions tagged or ask your own question.