## PHP can I add line numbers to file_get_contents()

Question

I have a private custom plugin that I just use on my multiple sites, and since I do a lot of debugging I find it easier to include the wp-config.php file contents in the admin area to ensure I have enabled/disabled debugging properly. Now I am training other designers to help with debugging, so I want to include line numbers similar to the theme/plugin editor. I retrieve the contents of the wp-config file using the file_get_contents() function. Is there a way I can add line numbers to this output?

Here is my function that gets the wp-config file contents:

function eriWpConfig(){
$wp_config = FALSE; if ( is_readable( ABSPATH . 'wp-config.php' ) )$wp_config = ABSPATH . 'wp-config.php';
elseif ( is_readable( dirname( ABSPATH ) . '/wp-config.php' ) )
$wp_config = dirname( ABSPATH ) . '/wp-config.php'; if ($wp_config )
$code = esc_html( file_get_contents($wp_config ) );
else
$code = 'wp-config.php not found'; echo '<pre class="code" >Installation path: ' . ABSPATH . "nn" .$code
. '</pre>';
}

0
5 months 2020-12-22T14:10:23-05:00 0 Answers 5 views 0