AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Php explode foreach loop12/30/2023 If you really wanna do it in Smarty, I'd suggest you write your own modifier, that gets a string and does exactly what the function in my first post does to it and returns the array. Breaks a string into an array of strings split on a given delimiter. So, what speaks agains processing the data in PHP so Smarty can display it easily?ītw, it is possible in Smarty, since you can use PHP function (such as explode) as modifiers, but I still think PHP is the better suited tool for that task. Using Smarty's foreach and explode I would like to build links like: But I have to do it with Smarty only.īecause that row comes with another rows as a result of a query. Of course you can do whatever you want with $b and $b in the loopĭarn computers always do what I tell them to instead of what I want them to do. Note: The 'separator' parameter cannot be an empty string. That's not really a Smarty related issue, is it?Īnyway, something along these lines should work for you: Definition and Usage The explode () function breaks a string into an array. I tried something but I can only get the first number, don't know how to get the date. $someVariabile2 = 5, $anotherVariable2 = PHP explode() function, run and write PHP code. After going through the first foreach loop. Not sure how to use foreach loops in PHP. If there is comma, split-explode using ', ' and iterate through. Common Mistake 1: Leaving dangling array references after foreach loops. Using foreach and explode how can I get result like: PHP mysqlquery() PHP Errors to Display PHP Loop For Do Foreach. I want to iterate through this string getting each item which are -> value (in first example) and -> value1 AND value2 in the second (without the comma or the dot in the end). I have the following entry in my database: Posted: Tue 6:09 pm Post subject: Using foreach with explode
0 Comments
Read More
Leave a Reply. |