Jump to content

PHP Explode Query


davblackpool

Recommended Posts

Hi Everyone

 

I'm getting really baffled by this and hope somebody can help.

 

I have a PHP get variable as follows:

 

eg: page.php?ad1=Any Road, London

 

I am wanting my PHP page to split that in two to create 2 separate echo's.. I've managed the first one where I can get the first part before the comma but am struggling to get the second part after the commar on another one.

 

This is the code I'm working with:

 

<?php
$ad1 =$_GET['ad1'];
 
$exploded = explode(',', $ad1);
 
$street1 = $exploded[0]; //Will contain part before % ?>
 
<?php
$ad1 =$_GET['ad1'];
 
$exploded = explode(',', ',', $ad1);
 
$town1 = $exploded[0]; //Will contain part before % ?>
 
 
 
<?php echo "$street1"; ?>
<?php echo "$town1"; ?>
 
 
Street1 is working perfectly but I can't get town1 to work.. it should ideally echo London when working.
 
Hope this makes sense, thanks in advance for any help :)
Link to comment
https://forums.phpfreaks.com/topic/284448-php-explode-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.