How do I convert an item from an array into a string variable


#1

I’m trying to get a string array containing the selected objects ( $objectsArray[ ] ), and then I would like to only get the first item from that array and put it into a regular string variable ( $onlyFirstObject )

string $objectsArray[] = ls -selection;
string $onlyFirstObject = $curvesArray[0];

This doesn’t work. What’s the correct way to get only the first item in a string array, and store it in a string variable?


#2

That should work, you’re just writing the wrong variable. $curvesArray isn’t $objectsArray.

string $objectsArray[] = ls -selection;
string $onlyFirstObject = $objectsArray[0];


#3

Duh, I’m an idiot. Thank you!