Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach ($countries as $country) {
- $country_id = $country['ID'];
- $country = get_the_title().", "; //comma
- echo "<pre>";var_dump($country);echo "</pre>";
- //string(6) "Taiwan, "
- //string(8) "Tanzania, "
- //string(14) "United Kingdom, "
- echo rtrim($country,", "); //Works not: Taiwan, Tanzania, United Kingdom,
- echo substr($country, 0, strlen($country)-1); //Works not: Taiwan, Tanzania, United Kingdom,
- echo substr($country, 0, -1); //Works not: Taiwan, Tanzania, United Kingdom,
- echo implode(", ", $country); //Works not: Warning: implode(): Invalid arguments passed
- echo $country[-1] = PHP_EOL; //Works not: (empty)
- echo substr($country, -1); //Works not: (empty)
- echo substr(trim($country), 0, -1); //Works not: Taiwan Tanzania United Kingdom
- echo str_replace(', ', '', $country); //Works not: TaiwanTanzaniaUnited Kingdom
- echo str_replace('', ', ', $country); //Works not: Taiwan, Tanzania, United Kingdom,
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement