Jump to content

Recommended Posts

Any ideas on how to determine the name and company name in this

format:

 

John Doe

John Doe Home Services

4748 National Rd E, Richmond, IN 47374

(765) 962-3908

johndoe@email.com

www.johndoe.com

 

 

Name: John Doe

Company Name: John Doe Home Services

Address: 4748 National Rd E, Richmond, IN 47374

Tel. No.: (765) 962-3908

Email: johndoe@email.com

Url: www.johndoe.com

 

 

I have a way in determining the tel. no., email

url.

:)

 

Ideas anyone?

Link to comment
https://forums.phpfreaks.com/topic/242744-address-parser/
Share on other sites

What are you wanting to do? Are you wanting to convert

John Doe
John Doe Home Services
4748 National Rd E, Richmond, IN 47374
(765) 962-3908
johndoe@email.com
www.johndoe.com

 

in to this format

Name:      John Doe
Company Name:   John Doe Home Services
Address:   4748 National Rd E, Richmond, IN 47374
Tel. No.:   (765) 962-3908
Email:      johndoe@email.com
Url:      www.johndoe.com

.

 

Where is this data coming from? And have you made any attempt at doing this yourself? Post your code here within


or


tags.

Link to comment
https://forums.phpfreaks.com/topic/242744-address-parser/#findComment-1246766
Share on other sites

I'm not trying to convert anything. I'm just trying to know if there

is a way to determine the name through it's company name with this format:

 

John Doe
John Doe Home Services
4748 National Rd E, Richmond, IN 47374
(765) 962-3908
johndoe@email.com
www.johndoe.com

 

What im trying to do here is store this in a database through this field:

Name

Company Name

Address

Tel. No.

Email

Url

 

 

Link to comment
https://forums.phpfreaks.com/topic/242744-address-parser/#findComment-1246779
Share on other sites

Yes, you can use explode combined with list to place each line into variables. Example code

<?php

//the data
$data = 'John Doe
John Doe Home Services
4748 National Rd E, Richmond, IN 47374
(765) 962-3908
johndoe@email.com
www.johndoe.com';

// standardise newlines to \n character
$data = str_replace(array("\r\n", "\r"), "\n", $data);

// put each line into variables
list($name, $companyName, $companyAddress, $telNumber, $email, $website) = explode("\n", $data);

?>
<!-- display the data -->
<b>Name</b>: <?php echo $name; ?><br />
<b>Company Name</b>: <?php echo $companyName; ?><br />
<b>Address</b>: <?php echo $companyAddress; ?><br />
<b>Tel. No.</b>: <?php echo $telNumber; ?><br />
<b>Email</b>: <?php echo $email; ?><br />
<b>Url</b>: <?php echo $website; ?>

Link to comment
https://forums.phpfreaks.com/topic/242744-address-parser/#findComment-1246784
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.