Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. foreach ($countries as $country) {
  2. $country_id = $country['ID'];
  3. $country = get_the_title().", "; //comma
  4.  
  5. echo "<pre>";var_dump($country);echo "</pre>";
  6. //string(6) "Taiwan, "
  7. //string(8) "Tanzania, "
  8. //string(14) "United Kingdom, "
  9.  
  10. echo rtrim($country,", "); //Works not: Taiwan, Tanzania, United Kingdom,
  11. echo substr($country, 0, strlen($country)-1); //Works not: Taiwan, Tanzania, United Kingdom,
  12. echo substr($country, 0, -1); //Works not: Taiwan, Tanzania, United Kingdom,
  13. echo implode(", ", $country); //Works not: Warning: implode(): Invalid arguments passed
  14. echo $country[-1] = PHP_EOL; //Works not: (empty)
  15. echo substr($country, -1); //Works not: (empty)
  16. echo substr(trim($country), 0, -1); //Works not: Taiwan Tanzania United Kingdom
  17. echo str_replace(', ', '', $country); //Works not: TaiwanTanzaniaUnited Kingdom
  18. echo str_replace('', ', ', $country); //Works not: Taiwan, Tanzania, United Kingdom,
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement