Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 371515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:07:18+00:00 2026-05-12T14:07:18+00:00

Ok, the idea here is to have code that will append SF_ to all

  • 0

Ok, the idea here is to have code that will append SF_ to all key names in an array.
I took my array (which is part of an object), flipped it, added the SF_, and flipped it back.

Somewhere in the process I lost some fields…

here’s what I started with:

object(stdClass)[12]
  public 'Affiliate_Code__c' => string 'XX-TXUJC3' (length=9)
  public 'AltEmail__c' => string 'benny@oxpublishing.com' (length=22)
  public 'City' => string 'Mobile' (length=6)
  public 'Email' => string 'benny@oxpublishing.com' (length=22)
  public 'Fax__c' => string '251-300-1234' (length=12)
  public 'FirstName' => string 'Benny' (length=5)
  public 'LastName' => string 'Butler' (length=6)
  public 'Phone' => string '251-300-3530' (length=12)
  public 'PostalCode' => string '36606' (length=5)
  public 'State' => string 'AL' (length=2)
  public 'Street' => string '851 E I-65 Service Rd' (length=21)
  public 'test1__c' => float 1
array
  'SF_Affiliate_Code__c' => string 'XX-TXUJC3' (length=9)
  'SF_Email' => string 'benny@oxpublishing.com' (length=22)
  'SF_City' => string 'Mobile' (length=6)
  'SF_Fax__c' => string '251-300-1234' (length=12)
  'SF_FirstName' => string 'Benny' (length=5)
  'SF_LastName' => string 'Butler' (length=6)
  'SF_Phone' => string '251-300-3530' (length=12)
  'SF_PostalCode' => int 36606
  'SF_State' => string 'AL' (length=2)
  'SF_Street' => string '851 E I-65 Service Rd' (length=21)

And here’s my code:

$response = $mySforceConnection->query(($query));



      foreach ($response->records as $SF) {
      }


        var_dump($SF);
        $SF = array_flip($SF);
            foreach ($SF as $key => $value){

                $SF[$key] = 'SF_'.$value;
                }

      $SF = array_flip($SF);
      echo "<pre>";
        var_dump($SF);
        echo "</pre>";
        extract($SF);

Any idea?
I’m new to OO programming of any sort, and I’m sure this has something to do with it.
I’m so stupid I have to do:

foreach ($response->records as $SF) { }

because I don’t know how to get to that array any other way.
Help!
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:07:19+00:00Added an answer on May 12, 2026 at 2:07 pm

    When you do the flip, you end up with duplicate keys – the values become the keys, and your values are not unique (e.g. Email and AltEmail__c both have the same value).

    Rather than doing a flip then flipping back, just create a new array and copy the values in with the new keys:

    $SF_new = array();
    foreach($SF as $key => $value ) {
       $SF_new['SF_' . $key] = $value;
    }
    
    // And if you want to continue using the $SF name...
    $SF = $SF_new;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the idea, I'd like to make a service? that will look for a
Here's the idea: you commit your code to a repository and call a web
Here's the basic idea: There is a java window (main) that opens another java
Here is my code: $('#right').load('textes.html #nicolas'); $('#right').load('textes.html #antoine'); The problem is that the content
Hey everyone... I'm not too familiar with PHP... but I have PHP code that
So, I have the following line of code, that does a for loop and
First of all I have seen that there are many questions about unrecognized selector
Here is the idea: When the user wants to see /controller/action, then I want
any idea which is the command for publish in msbuild corresponding to the one
Any idea on how to check whether that list is a subset of another?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.