Pulling content from one structure selected in another on the Front-End

I’ve got two social media structures set up on my website. One where users can set the different social media they want to be able to select sitewide:

  setsocial: 
    label: Set Social Platforms
    type: structure
    fields:
      platformname:
        label: Platform Name
        type: text  
      fillicon: 
        label: Platform Icon Fill
        type: files
        help: Make sure the icons have a transparent background!
        max: 1
        query: site.files
      buttonicon: 
        label: Platform Icon Button
        type: files
        max: 1
        query: site.files
      inverticon: 
        label: Platform Icon Inverted
        type: files
        max: 1
        query: site.files

and another where they can then set the specific URLs and platforms for different instances across the site:

label: Social
type: structure
fields:
  platform:
    label: Platform
    type: select
    width: 1/2
    options: query
    query: 
      fetch: site.setsocial.toStructure
      text: "{{ structureItem.platformName }}"
      value: "{{ structureItem }}"
  url:
    label: URL
    type: text
    width: 1/2

I’ve been trying to figure out how in my snippet to pull through contents from one structure to another. Using structureItem as a value this YAML seems to pass through an array because things like this get me array to string conversion errors:

<?php foreach($links as $sitem):
    $splatform = $sitem->platform();
    $spurl = $sitem->url();
    ?>
  <?= $splatform->yaml() ?>
<?php endforeach ?>

but then when I try to access the content like an array such as

<?= $splatform[0] ?>

I then get an error that it can’t be treated like an array. Is there a better way to access the setSocial structure content? (specifically the images) and does something like {{ structureItem }} actually even work?

I don’t think it makes sense to store the structureItem, store the platformName as value.

then in the front-end would I match the values from setSocial and Social to get the other information out of the structure?

What I ended up doing:

<?php foreach($site->setsocial()->toStructure() as $sstructure): ?>
  <?php if($sstructure->platformname()->toString() == $splatform->toString()): ?>
    <a class="<?= $splatform ?>" href="<?= $sitem->url() ?>">
      <?php if($invert == true ):?>
        <?= $sstructure->inverticon()->toFile() ?>
      <?php else: ?>
        <?= $sstructure->buttonicon()->toFile() ?>
      <?php endif ?>
    </a>
  <?php endif ?>
<?php endforeach ?>

EDIT: $invert is defined in the snippet like so: <?php snippet('social-links', ['links' => $site->social()->toStructure(), 'invert' => true]) ?>

It is not necessary to loop through the whole structure to find a specific item:

$socialItems  = $site->setsocial()->toStructure();
$specificItem = $socialItems->findBy('platformname', $splatform->value());

Using specificItem is giving me a null error when passing it through an if statement and only gives me numbers instead of the actual value.