 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to capture the result of var_dump to a string in PHP?\\n
The resultant value of var_dumo can be extracted to a string using ‘output buffering’. Below is an example demonstrating the same −
Example
<?php    function varDumpToString($var) {       ob_start();       var_dump($var);       $result = ob_get_clean();       return $result;    }    //usage    $data = array('first', 'second', 'third');    $result = varDumpToString($data);    echo $result; The output control function helps in obtaining the output of a function and saving it to a string variable. In general, the output of a PHP code is usually displayed on a browser.
Output
This will produce the following output −
array(3) { [0]=> string(5) "first" [1]=> string(6) "second" [2]=> string(5) "third" }Advertisements
 