I have no idea and wanted to see if anyone has ever done such a thing:
If I have a class that connects to an API and returns field names such as:
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($userName, $password);
//$result = $client->describeGlobal();
$result = $client->describeSObject("Account");
echo '<pre>' . print_r($result->fields, true) . '</pre>';
and that returns:
Array
(
[0] => stdClass Object
(
[autoNumber] =>
[byteLength] => 18
[calculated] =>
[caseSensitive] =>
[createable] =>
[custom] =>
[defaultedOnCreate] => 1
[digits] => 0
[filterable] => 1
[label] => Account ID
[length] => 18
[name] => Id
[nameField] =>
[namePointing] =>
[nillable] =>
[precision] => 0
[restrictedPicklist] =>
[scale] => 0
[soapType] => tns:ID
[sortable] => 1
[type] => id
[unique] =>
[updateable] =>
)
[1] => stdClass Object
(
[autoNumber] =>
[byteLength] => 0
[calculated] =>
[caseSensitive] =>
[createable] =>
[custom] =>
[defaultedOnCreate] => 1
[digits] => 0
[filterable] => 1
[label] => Deleted
[length] => 0
[name] => IsDeleted
[nameField] =>
[namePointing] =>
[nillable] =>
[precision] => 0
[restrictedPicklist] =>
[scale] => 0
[soapType] => xsd:boolean
[sortable] => 1
[type] => boolean
[unique] =>
[updateable] =>
)
Is there a way to create variables on the fly for each $result->fields->name in an array? something like this:
$try = array();
$try = compact($result->fields->name);
echo '<pre>' . print_r($try, true) . '</pre>';
Now I know that does not work, but was wondering if something like this is possible, instead of having to do a long block of code like this:
$pass_this = array();
$pass_this['name'] = $results->fields->name
$pass_this['type '] = $results->fields->type
maybe this is confusing, sorry if it is!