简体   繁体   中英

unique string from array of strings

I want to create a string that is unique from all the strings in an array. I know that unique_array would create an array with unique values, but I want to create a new string that is unique from all the strings in the unique array. I want this in PHP.

For example, if I have "1" , "2" strings in the unique array. I would like to create a "3" string or "a" string or any other string with a different name then "1" , and "2" . Serialize a new string and add it into the array and check for unique_array sounds like it should work, but is there a simpler way to do it?

How about

sort($array);
$array[] = end($array) + 1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM