How to get the language code when a language name is given? We are creating nodes programmatically on submitting a form. The language of a node is an input value in the form.
How can I get the langcode, when I have the Language name?

For example, user may type English. So i should convert it to "en"

If there an in-built function for that?
You can do it with this code.

// Language to search.
$find = 'French';

// Getting all the available languages.
$languages = \Drupal::service('language_manager')-&gt;getStandardLanguageList();

$key = key(array_filter($languages, function ($array) use ($find) {
  if (array_search($find, $array) === FALSE) {
    return FALSE;
  }
  return TRUE;
}));

// If you have the devel module installed you can use the dpm function.
dpm($key);