Skip to content

Instantly share code, notes, and snippets.

@amorkovin
Last active August 18, 2020 13:27
Show Gist options
  • Save amorkovin/b77cf085743bef49913e7081c4501ccd to your computer and use it in GitHub Desktop.
Save amorkovin/b77cf085743bef49913e7081c4501ccd to your computer and use it in GitHub Desktop.
Убрать пробелы у всех элементов массива
<?php
$get_cat_ids_not_parce = explode(',', $get_cat_ids_not_parce);
$get_cat_ids_not_parce = array_map('trim', $get_cat_ids_not_parce);
// Если значения должны быть только целами числами
foreach ($get_cat_ids_not_parce as $index => $value) {
$get_cat_ids_not_parce[$index] = (int)$value;
}
$get_cat_ids_not_parce = array_diff($get_cat_ids_not_parce, array(0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment