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 :: php get domain from url 
Php :: laravel checkbox terms and conditions 
Php :: unique sql queries laravel 
Php :: composer create-project --prefer-dist laravel/laravel blog 
Php :: get file name from file path in php 
Php :: drupal 9 enable PHP errors 
Php :: php salto de linea 
Php :: Undefined property: CollectiveAnnotationsRoutingAnnotationsResourcePath::$no_prefix 
Php :: laravel faker examples 
Php :: join 2 tables laravel 
Php :: composer create-project laravel/laravel --prefer-dist laravel-bootstrap 
Php :: php return json response with status code 
Php :: codeigniter count rows 
Php :: confirm password validation laravel 
Php :: translate youtube link into iframe in laravel 
Php :: php verify associative array key eixsts 
Php :: php current date get 
Php :: wp_query post by category id 
Php :: php pdo Check if row exists in the database 
Php :: php home url 
Php :: php function to convert string to camelcase 
Php :: convert dd/mm/yyyy to yyyy-mm-dd in mysql php 
Php :: integer nullable laravel 
Php :: how to create compomemt in laravel livewire 
Php :: overwrite file php 
Php :: php index of last element in array 
Php :: How to insert time in table using CodeIgniter 
Php :: how to return variable from transaction laravel 
Php :: laravel required only one of multiple fields not both 
Php :: install phpmyadmin linux 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =