Jump to content

preg_match and var_dump question


acctman

Recommended Posts

I have 3 questions

1. how do I use the var_dump($parts); code to set $city $state $zip.

2. using the same similar code I need to change the preg_match to separate  "London, H9"

3. using the same similar code I need to change the preg_match to separate  "PARADISE, NL A1L1P1"

thanks in advance.

 

$uscountry = $_POST['locus']; // New York, NY 10011
preg_match("/(.*)\,\s+([A-Z]{2})\s+([\d]+)/", $uscountry, $parts);  
var_dump($parts);  

Link to comment
https://forums.phpfreaks.com/topic/197775-preg_match-and-var_dump-question/
Share on other sites

This will assign the part to a variable

$variable = $parts['array_key_here'];

 

 

what would the array_key be? can you help me with all 3 of my questions. I've been at this for the past 2hrs. I want to get this completed so I can work on something else. thanks

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.