How to separate an array - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How to separate an array (/showthread.php?tid=34723) |
How to separate an array - El Forum - 10-07-2010 [eluser]JayArias[/eluser] I am currently trying to separate these tags from my database. What happens is that every item in the catalog has a tags section where users can input tags like: Green, Apples, Awesome and I need it to come back out from the function like so Code: #Green, #Apples Just keep in mind I need to separate the tags so I can send the user to /viewby/tags/apples when they click on the #apples tag. Code: function loadTags() Code: #business,masters,music,sound,grey#green, toro, bull, mens#######exclimation, person, awesomeness, girl, white, black#fishie, grey, blue, tank, tank-top#flamingo, love, red, tank-top, tanktop, white, drip How to separate an array - El Forum - 10-07-2010 [eluser]Twisted1919[/eluser] Code: $tags = array(); Should work, not sure though. How to separate an array - El Forum - 10-07-2010 [eluser]CroNiX[/eluser] before your foreach, do a print_r($row); I have a feeling your result is because the result from the database is one long string and not separate tags like you are expecting (from your code anyway). If thats the case, in your foreach you can Code: $tags = array(); How to separate an array - El Forum - 10-07-2010 [eluser]Twisted1919[/eluser] Ha, pretty much the same ha ? How to separate an array - El Forum - 10-07-2010 [eluser]JayArias[/eluser] Code: Array ( [0] => #business [1] => #masters [2] => #music [3] => #sound [4] => #grey ?? lmao How to separate an array - El Forum - 10-07-2010 [eluser]CroNiX[/eluser] Yeah, that IS funny. How to separate an array - El Forum - 10-07-2010 [eluser]JayArias[/eluser] Fixed that bug, but for some crazy reason it's only pulling the tags from the first db entry. I need all of them. How to separate an array - El Forum - 10-07-2010 [eluser]CroNiX[/eluser] Post your code and your db schema. Hard to give complete answers without the complete info. How to separate an array - El Forum - 10-07-2010 [eluser]JayArias[/eluser] Code: $this->db->select('tags'); How to separate an array - El Forum - 10-07-2010 [eluser]CroNiX[/eluser] Please post the contents of the $row array. Code: $this->db->select('tags'); |