Hi there,
i am trying to get a variable out of a result from a for each loop. So i build my table structure with everything in it. The result of this i want to put into a variable so it can be replaced in a template.
So far i used
echo stripslashes(str_replace(array('###MENU###','###TEXT###'),array("THIS SHOULD BE A VARIABLE INSTEAD OF TEXT",$replace2),$message));
Who can help me out and tell me how to do this?
Kind regards
Robbie
make variable from foreach result
Moderator: General Moderators
-
RobbertvanOs
- Forum Newbie
- Posts: 9
- Joined: Wed Jul 02, 2003 2:43 pm
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
Robbie,
Uhm robbie...i think you need to be a lil more elaborate on your question but
see i dont no what your $array_val is but it seems to be an inner array to $item_in_array and it seems your subject is a string of text
if your search is and array with the template markings then you need to go trhough some order sorting usually you try to replace $array_val with the corresponding $search[$key] that's if every thing is sorted/ organised in a certain order
i hope im not going off base here but perhaps you can follow or me more detailed
Kendall
Uhm robbie...i think you need to be a lil more elaborate on your question but
Code: Select all
foreact($item_in_array as $key => $array_val){
echo stripslashes(str_replace($search,$array_val,$subject));
}if your search is and array with the template markings then you need to go trhough some order sorting usually you try to replace $array_val with the corresponding $search[$key] that's if every thing is sorted/ organised in a certain order
i hope im not going off base here but perhaps you can follow or me more detailed
Kendall
-
RobbertvanOs
- Forum Newbie
- Posts: 9
- Joined: Wed Jul 02, 2003 2:43 pm
Hi kendall,
Thank you for your answer, i had a very unclear question about my loop. I found out that the problem wasn't in there, but the problem was the way i build a variable. I set a variable in a loop and everytime i looped over it, it resetted itself. I found out that i had to set the variable empty before the loop and that after that the variable summing up worked.
So thank you for your quick response and as soon as i have another question i'll be back
Many thanks,
Kind regards,
Robbie
Thank you for your answer, i had a very unclear question about my loop. I found out that the problem wasn't in there, but the problem was the way i build a variable. I set a variable in a loop and everytime i looped over it, it resetted itself. I found out that i had to set the variable empty before the loop and that after that the variable summing up worked.
So thank you for your quick response and as soon as i have another question i'll be back
Many thanks,
Kind regards,
Robbie