Change Variable based on other

What seems to be the problem:
I have:

and

public $value = ‘phases.phase’;
public $plural = ‘phases’;
public $singular = ‘phase’;

When i select and option the value of $value is correctly changed.

How do i change the other 2 based on the first one?

public function mount()
{
$this->plural = explode(’.’,$this->value)[0];
$this->singular = explode(’.’,$this->value)[1];
}

Isn’t working :frowning:

I’m not sure, but you may want to put the two words in $value into an array:

public $value = ['phases', 'phase'];

Then you would simply do:

public function mount()
{
$this->plural = $this->value[0];
$this->singular = $this->value[1];
}

I have not tried it, but something like that.

thnx. But how do i pass the select dropdown value to the created array?

public $value = ['phases', 'phase'];

the logic of your code works, as you can see in the link below

https://rextester.com/TTCO14783

<?php

$value = 'phases.phase';
$plural = 'phases';
$singular = 'phase';

$plural = explode('.',$value)[0];
$singular = explode('.',$value)[1];

echo $plural;
echo "\n";
echo $singular;
    
?>