4xjbh Posted July 11, 2013 Share Posted July 11, 2013 My php code is currently separated from my html, at least as much as possible without using a framework or template system. I am echoing out $result['title'] in my html, is there an easy way to convert it to a variable so I can use $title instead? current html: <?php foreach ($results as $row): ?> <?php echo $row['title'] ?> <?php echo $row['description'] ?> <?php endforeach; ?> php: $results=$conn->query($sql); Link to comment https://forums.phpfreaks.com/topic/280055-array-to-variable/ Share on other sites More sharing options...
fastsol Posted July 11, 2013 Share Posted July 11, 2013 $title = $row['title']; Link to comment https://forums.phpfreaks.com/topic/280055-array-to-variable/#findComment-1440261 Share on other sites More sharing options...
web_craftsman Posted July 11, 2013 Share Posted July 11, 2013 You may consider using http://php.net/manual/en/function.list.php Link to comment https://forums.phpfreaks.com/topic/280055-array-to-variable/#findComment-1440268 Share on other sites More sharing options...
AbraCadaver Posted July 11, 2013 Share Posted July 11, 2013 I don't use it anymore and it may be frowned upon, especially with un-trusted data, but look at extract(). Link to comment https://forums.phpfreaks.com/topic/280055-array-to-variable/#findComment-1440314 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.