php - Using values inside a function out side -
Is it possible to use values that are received within loop / function outside the loop / function, where Is it used or called?
Below is my job
function closed ($ border) {$ string = file_get_contents ("feed.xml"); $ XML = simplexml_load_string ($ string); Forex Currency ($ xml-> Found-> as CAT $ location) {$ limits = $ place-> CORDS; $ Rate = $ place-> Stars; $ Phone = $ place-> phone; }}
Calling it in a php file containing html tag is it possible to get values that are returned in the rows by the function which marked xxxx to display goes?
& lt; Html & gt; & Lt; Body & gt; & Lt ;? Php off ('57854'); ? & Gt; & Lt; The width of the table = "200" range = "1" & gt; & Lt; TR & gt; & Lt; TD & gt; Xxxxx & lt; / TD & gt; & Lt; TD & gt; Xxxxx & lt; / TD & gt; & Lt; TD & gt; Xxxxx & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Xxxxx & lt; / TD & gt; & Lt; TD & gt; Xxxxx & lt; / TD & gt; & Lt; TD & gt; Xxxxx & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Xxxxx & lt; / TD & gt; & Lt; TD & gt; Xxxxx & lt; / TD & gt; & Lt; TD & gt; Xxxxx & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Body & gt; & Lt; / Html & gt;
I would like to know that there is a way to display without adding the html tags within the function.
Any help would be appreciated.
>
Well, you can loop without PHP, so Your HTML should be inside a loop. But if you help, you can return the simplified array from your function:
function closed ($ border) {$ string = file_get_contents ("feed.xml"); $ Xml = simplexml_load_string ($ string); $ Return = array (); Forex Currency ($ xml-> Found-> as CAT $$) {$ return [] = Array ('Borders => $ place-> CORDS,' Rate '= & gt; $ Place-> STARS, 'phone' = & gt; $ place- & gt; PHONE)} returns $ return; }
The function now creates an array of results to return the caller, then you can just loop through that array:
& Lt; Html & gt; & Lt; Body & gt; & Lt ;? Php $ arr = off ('57854'); ? & Gt; & Lt; The width of the table = "200" range = "1" & gt; & Lt ;? Php foreach ($ arr $ as line):? & Gt; & Lt; TR & gt; & Lt; Td> & Lt ;? Php echo $ line ['border']; ? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ line ['rate']; ? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ row ['phone']; ? & Gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php endforeach; ? & Gt; & Lt; / Table & gt; & Lt; / Body & gt; & Lt; / Html & gt;
In this way, you can avoid having HTML inside your function, which is always a good thing & ndash; Keep your logic separate from the presentation.
Comments
Post a Comment