Need Help with Array

  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

It's been a while since I've done any programming and I'm getting hung up on this one. I need this to result in separte fields; however, it's just coming back as one long string from $results.

Code: [ Select ]
while (strlen($ssn)<9) $ssn='0'.$ssn;
        $result= $this->search_object('User','SSN',$ssn);
        
        foreach ($result as $u) {
            $contact=$u->findChild('ContactInfo',array(),false,true);
            $fname=$contact->FirstName;
            $lastname=$contact->LastName;
            echo $fname;
            echo $lastname;
            
        }
        
        foreach ($result as $u) {
            $address=$u->findChild('Address',array(),false,true);
            $line1=$address->Line1;
            $line2=$address->Line2;
            $city=$address->City;
            $State=$address->State;
            $Zip=$address->Zipcode;
            echo $line1;
            echo $line2;
            echo $city;
            echo $State;
            echo $Zip;
            
        }
        
        foreach ($result as $u) {
            $contactinfo=$u->findChild('ContactInfo',array(),false,true);
            $phone=$contactinfo->HomePhone;
            echo $phone;
            
        }
  1. while (strlen($ssn)<9) $ssn='0'.$ssn;
  2.         $result= $this->search_object('User','SSN',$ssn);
  3.         
  4.         foreach ($result as $u) {
  5.             $contact=$u->findChild('ContactInfo',array(),false,true);
  6.             $fname=$contact->FirstName;
  7.             $lastname=$contact->LastName;
  8.             echo $fname;
  9.             echo $lastname;
  10.             
  11.         }
  12.         
  13.         foreach ($result as $u) {
  14.             $address=$u->findChild('Address',array(),false,true);
  15.             $line1=$address->Line1;
  16.             $line2=$address->Line2;
  17.             $city=$address->City;
  18.             $State=$address->State;
  19.             $Zip=$address->Zipcode;
  20.             echo $line1;
  21.             echo $line2;
  22.             echo $city;
  23.             echo $State;
  24.             echo $Zip;
  25.             
  26.         }
  27.         
  28.         foreach ($result as $u) {
  29.             $contactinfo=$u->findChild('ContactInfo',array(),false,true);
  30.             $phone=$contactinfo->HomePhone;
  31.             echo $phone;
  32.             
  33.         }


Any help would be greatly appreciated.

Thanks!!!!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

We really need more info to help you out BUT based on the info you provided I Might know whats going on.

So lets start by looking at this. I really don't know how the function actually works but to me it looks like it is telling me to look into the object and find the address and return it as an array and that the person sitting to my right is not funny and the person to my left is dumb as a brick (J/K I don't know what false true do)
jordonshaw wrote:
$address=$u->findChild('Address',array(),false,true);


Now if this is correct we should have an array containing the address parts. So this looks like your treating it like it is still and object
jordonshaw wrote:
$line1=$address->Line1;
$line2=$address->Line2;
$city=$address->City;
$State=$address->State;
$Zip=$address->Zipcode;
echo $line1;
echo $line2;
echo $city;
echo $State;
echo $Zip;


Try something like this instead
PHP Code: [ Select ]
$line1 = $address['Line1'];
$line2 = $address['Line2'];
$city  = $address['City'];
$State = $address['State'];
$Zip   = $address['Zipcode'];
 
echo $line1;
echo $line2;
echo $city;
echo $State;
echo $Zip;
 
  1. $line1 = $address['Line1'];
  2. $line2 = $address['Line2'];
  3. $city  = $address['City'];
  4. $State = $address['State'];
  5. $Zip   = $address['Zipcode'];
  6.  
  7. echo $line1;
  8. echo $line2;
  9. echo $city;
  10. echo $State;
  11. echo $Zip;
  12.  


If this solves your issue do the same with the contact info
  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

Thank you. I was able to get this working.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 81 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.