I'm working on some Magento order export using SOAP and sales_order.info Using the shipping_address I'm able to get the obejct street. However this seem to include both Street 1 and Street 2. Which is the way of extracting both street 1st line and 2nd line, as I need to pass these values as two different fields to a separate system?

I use $shipdata['shipping_address']['street']

  • I'm sure $shipdata['shipping_address']['street'] is an array. But do var_dump($shipdata['shipping_address']['street']) in your code to confirm. – Barry Carlyon Sep 25 '14 at 10:32

The street field contains street1 and street2 separated by a line break. In order to get one or the other just explode the string by \n.

$street = explode('\n', $street);

You can then just pull $street[0] for street1 or $street[1] for street2. Alternatively if you are accessing the customer address object you can just call street1 or street2 directly to do the same thing:

$street1 = $address->getStreet1();
$street2 = $address->getStreet2();
  • Exploade doesent work for some reason: code $street = explode('\n', $shipdata['shipping_address']['street']); echo $street[0] . '<br>'; echo $street[1] . '<br>';code – Andreas Sep 25 '14 at 11:35
  • I can assure you it is the way the address lines are stored. – Jonathan Hussey Sep 25 '14 at 11:36
  • Both rows are in street[0] so for some reason it does not pickup the linebreak – Andreas Sep 25 '14 at 11:38
  • 2
    Replaced '\n' with "\n" Now its working – Andreas Sep 25 '14 at 13:31
  • Hi. Just in case if you need to add 2 street lines when creating address programmatically (my situation when I came to this usefull post), just apply it like that: $address->setStreet( $streetLine1 ."\n". $streetLine2); – DarkCowboy Apr 20 '17 at 10:28


$customerAddress = Mage::getModel('customer/address')->load($customerAddressId);

$street = $customerAddress->getStreet();
$street0 = strtolower($street[0]);
$street1 = strtolower($street[1]);

//set "street0" as customer address...
if($street0 == $street1){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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