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 sidebar menu active 
:: check empty laravel blade 
Php :: laravel join query sum example 
Php :: how to add dummy records using factory in laravel 8 
Php :: switch php 
Php :: php form get 
Php :: get table name of model laravel inside the model 
Php :: for i php 
Php ::  
::  
Php ::  
Php ::  
Php ::  
:: install php debian 10 
Php ::  
Php :: current user laravel 
Php :: prestashop get all products 
Php :: update json file php 
Php ::  
Php :: php why " " not new line 
Php :: carbon finer 
Php ::  
::  
:: include and require in php 
Php ::  
Php :: laravel validation max string length 
Php :: get last id in laravel 
Php :: php multi type parameter php multi type parameter 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =