Search
 
SCRIPT & CODE EXAMPLE
 

PHP

array to table php

    function build_table($array){
    // start table
    $html = '<table>';
    // header row
    $html .= '<tr>';
    foreach($array[0] as $key=>$value){
            $html .= '<th>' . htmlspecialchars($key) . '</th>';
        }
    $html .= '</tr>';

    // data rows
    foreach( $array as $key=>$value){
        $html .= '<tr>';
        foreach($value as $key2=>$value2){
            $html .= '<td>' . htmlspecialchars($value2) . '</td>';
        }
        $html .= '</tr>';
    }

    // finish table and return it

    $html .= '</table>';
    return $html;
}

$array = array(
    array('first'=>'tom', 'last'=>'smith', 'email'=>'tom@example.org', 'company'=>'example ltd'),
    array('first'=>'hugh', 'last'=>'blogs', 'email'=>'hugh@example.org', 'company'=>'example ltd'),
    array('first'=>'steph', 'last'=>'brown', 'email'=>'steph@example.org', 'company'=>'example ltd')
);

echo build_table($array);
Comment

array to table php

<?php
$array = array(
    "foo" => "bar",
    "bar" => "foo",
    100   => -100,
    -100  => 100,
);
var_dump($array);
?>
Comment

html table to array php

<?php

	$htmlContent = file_get_contents("http://teskusman.esy.es/index.html");
		
	$DOM = new DOMDocument();
	$DOM->loadHTML($htmlContent);
	
	$Header = $DOM->getElementsByTagName('th');
	$Detail = $DOM->getElementsByTagName('td');
?>
Comment

PREVIOUS NEXT
Code Example
Php :: ? in php 
Php :: php get current date 
Php :: how to get the ip address of the client in php 
Php :: how to push associative array in php 
Php :: laravel 6 migration add column to existing table 
Php :: how to store array in variable php 
Php :: php date format dd-mm-yyyy 
Php :: $this 
Php :: how to host a php server 
Php :: how to do taxonomy filter in wordpress 
Php :: Attempt to read property "name" on bool 
Php :: crrate model in laravel 
Php :: schema add column laravel 
Php :: how to convert string to int in php laravel 
Java :: when is the first day of spring 
Java :: spigot broadcast message 
Java :: Console color text java 
Java :: jcenter is at end of life 
Java :: phone call using intent in Android 
Java :: Cannot resolve class android.support.design.widget.AppBarLayout 
Java :: android how to split string 
Java :: get intent not working in fragment 
Java :: open webpage android studio 
Java :: array to map javax 
Java :: java random between 
Java :: jframe add label java 
Java :: init cap java 
Java :: java jackson cast to list 
Java :: fullscreen in java 
Java :: -Xlint:deprecation 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =