Come dividere la string dal contenuto mesh e aggiungere l'elemento html

Ho ottenuto un risultato da whois risultato della ricerca come pugno di contenuto voglio rendere il text in grassetto o aggiungere qualsiasi altro elemento HTML prima del ':' Frase e anche dopo ':'

mazzetto di contenuti es.

devims.com domain lookup results from whois.PublicDomainRegistry.com server: Domain Name: DEVIMS.COM Registry Domain ID: 1615408964_DOMAIN_COM-VRSN Registrar WHOIS Server: whois.publicdomainregistry.com Registrar URL: www.publicdomainregistry.com Updated Date: 2012-05-30T12:18:42Z Creation Date: 2010-09-12T14:54:29Z Registrar Registration Expiration Date: 2016-09-12T14:54:29Z Registrar: PDR Ltd. d/b/a PublicDomainRegistry.com Registrar IANA ID: 303 Registrar Abuse Contact Email: [email protected] Registrar Abuse Contact Phone: +1-2013775952 Domain Status: clientTransferProhibited (http://icann.org/epp#clientTransferProhibited) Registry Registrant ID: Registrant Name: devi sri mari Registrant Organization: devIMS Registrant Street: No.53, First Street, SS Nagar, Thirumullaivoiyal, Registrant City: Chennai Registrant State/Province: Tamil Nadu Registrant Postal Code: 600062 Registrant Country: IN Registrant Phone: +044.42839080 Registrant Phone Ext: Registrant Fax: Registrant Fax Ext: Registrant Email: [email protected] Registry Admin ID: Admin Name: devi sri mari Admin Organization: devIMS Admin Street: No.53, First Street, SS Nagar, Thirumullaivoiyal, Admin City: Chennai Admin State/Province: Tamil Nadu Admin Postal Code: 600062 Admin Country: IN Admin Phone: +044.42839080 Admin Phone Ext: Admin Fax: Admin Fax Ext: Admin Email: [email protected] Registry Tech ID: Tech Name: devi sri mari Tech Organization: devIMS Tech Street: No.53, First Street, SS Nagar, Thirumullaivoiyal, Tech City: Chennai Tech State/Province: Tamil Nadu Tech Postal Code: 600062 Tech Country: IN Tech Phone: +044.42839080 Tech Phone Ext: Tech Fax: Tech Fax Ext: Tech Email: [email protected] Name Server: ns743.hostgator.com Name Server: ns744.hostgator.com DNSSEC:Unsigned URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/ >>>Last update of WHOIS database: 2015-02-11T04:42:33+0000Z<<< For more information on Whois status codes, please visit https://icann.org/epp Registration Service Provided By: HOSTMACRO WEB SERVICES The data in this whois database is provided to you for information purposes only, that is, to assist you in obtaining information about or related to a domain name registration record. We make this information available "as is", and do not guarantee its accuracy. By submitting a whois query, you agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to: (1) enable high volume, automated, electronic processes that stress or load this whois database system providing you this information; or (2) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via direct mail, electronic mail, or by telephone. The compilation, repackaging, dissemination or other use of this data is expressly prohibited without prior written consent from us. The Registrar of record is PDR Ltd. d/b/a PublicDomainRegistry.com. We reserve the right to modify these terms at any time. By submitting this query, you agree to abide by these terms 

output prevista in html

 eg. <li>Registrar WHOIS Server</li>: <li>whois.publicdomainregistry.com </li> or eg. <b>Registrar WHOIS Server</b>: <li>whois.publicdomainregistry.com </li> eg. <li>Registrar WHOIS Server</li>: <li>whois.publicdomainregistry.com </li> or eg. <b>Registrar WHOIS Server:</b> <li>whois.publicdomainregistry.com </li> 

Quello che ho provato: My Code

  $result = "Registrar WHOIS Server: whois.publicdomainregistry.com Registrar URL: www.publicdomainregistry.com Updated Date: 2012-05-30T12:18:42Z Creation Date: 2010-09-12T14:54:29Z Registrar Registration Expiration Date: 2016-09-12T14:54:29Z Registrar: PDR Ltd. d/b/a PublicDomainRegistry.com Registrar IANA ID: 303 Registrar Abuse Contact Email: [email protected]ublicdomainregistry.com Registrar Abuse Contact Phone: +1-2013775952 Domain Status: clientTransferProhibited (http://icann.org/epp#clientTransferProhibited) Registry Registrant ID: Registrant Name: devi sri mari Registrant Organization: devIMS Registrant Street: No.53, First Street, SS Nagar, Thirumullaivoiyal, Registrant City: Chennai Registrant State/Province: Tamil Nadu Registrant Postal Code: 600062 Registrant Country: IN Registrant Phone: +044.42839080 Registrant Phone Ext: Registrant Fax: Registrant Fax Ext: Registrant Email: [email protected]"; echo $result; $res = explode( ': ', $result ); foreach ($res as $value) { echo '<li>'. $value .'</li>'; } print_r( explode( ': ', $result ) ); 

Produzione

  Array ( [0] => Registrar WHOIS Server [1] => whois.publicdomainregistry.com Registrar URL [2] => www.publicdomainregistry.com Updated Date [3] => 2012-05-30T12:18:42Z Creation Date [4] => 2010-09-12T14:54:29Z Registrar Registration Expiration Date [5] => 2016-09-12T14:54:29Z Registrar [6] => PDR Ltd. d/b/a PublicDomainRegistry.com Registrar IANA ID [7] => 303 Registrar Abuse Contact Email [8] => [email protected] Registrar Abuse Contact Phone [9] => +1-2013775952 Domain Status [10] => clientTransferProhibited (http://icann.org/epp#clientTransferProhibited) Registry Registrant ID [11] => Registrant Name [12] => devi sri mari Registrant Organization [13] => devIMS Registrant Street [14] => No.53, First Street, SS Nagar, Thirumullaivoiyal, Registrant City [15] => Chennai Registrant State/Province [16] => Tamil Nadu Registrant Postal Code [17] => 600062 Registrant Country [18] => IN Registrant Phone [19] => +044.42839080 Registrant Phone Ext [20] => Registrant Fax [21] => Registrant Fax Ext [22] => Registrant Email [23] => [email protected] ) 

output prevista

  Array ( [0] => Registrar WHOIS Server [1] => whois.publicdomainregistry.com [2] => Registrar URL [3] => www.publicdomainregistry.com [4] => Updated Date [5] => 2012-05-30T12:18:42Z [6] => reation Date [7] => 2010-09-12T14:54:29Z [8] => Registrar Registration Expiration Date [9] => 2016-09-12T14:54:29Z [10] => Registrar URL [11] => PDR Ltd. d/b/a PublicDomainRegistry.com [12] => Registrar IANA ID .... ) 

Direi che il vero problema qui è che hai rimosso le newline dall'output whois. Se avessi mantenuto le newline, avresti dovuto essere in grado di separare meglio le chiavi dai valori. Ora non c'è un buon modo per dire cosa è parte di un valore e cosa fa parte della prossima chiave, ed è per questo che l'output risultante li ha confusi.

Quindi, cerca di get l'output whois senza che i newline vengano rimossi. Quindi puoi fare questo:

 // Note: Newlines added to $result below (and string shortened a bit) $result = "Registrar WHOIS Server: whois.publicdomainregistry.com\nRegistrar URL: www.publicdomainregistry.com\nUpdated Date: 2012-05-30T12:18:42Z\nCreation Date: 2010-09-12T14:54:29Z\nRegistrar Registration Expiration Date: 2016-09-12T14:54:29Z\nRegistrar: PDR Ltd. d/b/a PublicDomainRegistry.com"; $out = arrays(); $rows = explode("\n", $result); foreach ($rows as $row) { preg_match('/(.*?)\: (.*)/', $row, $matches); $out[] = $matches[1]; // Key $out[] = $matches[2]; // Value } print_r($out); 

Produzione:

 Array ( [0] => Registrar WHOIS Server [1] => whois.publicdomainregistry.com [2] => Registrar URL [3] => www.publicdomainregistry.com [4] => Updated Date [5] => 2012-05-30T12:18:42Z [6] => Creation Date [7] => 2010-09-12T14:54:29Z [8] => Registrar Registration Expiration Date [9] => 2016-09-12T14:54:29Z [10] => Registrar [11] => PDR Ltd. d/b/a PublicDomainRegistry.com ) 

Se sei davvero bloccato con l'output whois senza newline, dovrai conoscere tutte le chiavi che ti interessano e rendere la separazione tra chiavi e valori basata su questo, piuttosto che solo i due punti:

 $result = "Registrar WHOIS Server: whois.publicdomainregistry.com Registrar URL: www.publicdomainregistry.com Updated Date: 2012-05-30T12:18:42Z Creation Date: 2010-09-12T14:54:29Z Registrar Registration Expiration Date: 2016-09-12T14:54:29Z Registrar: PDR Ltd. d/b/a PublicDomainRegistry.com Registrar IANA ID: 303 Registrar Abuse Contact Email: [email protected] Registrar Abuse Contact Phone: +1-2013775952 Domain Status: clientTransferProhibited (http://icann.org/epp#clientTransferProhibited) Registry Registrant ID: Registrant Name: devi sri mari Registrant Organization: devIMS Registrant Street: No.53, First Street, SS Nagar, Thirumullaivoiyal, Registrant City: Chennai Registrant State/Province: Tamil Nadu Registrant Postal Code: 600062 Registrant Country: IN Registrant Phone: +044.42839080 Registrant Phone Ext: Registrant Fax: Registrant Fax Ext: Registrant Email: [email protected]"; $keys = arrays("Registrar WHOIS Server", "Registrar URL", "Registrar WHOIS Server", "Registrar URL", "Updated Date", "Creation Date", "Registrar Registration Expiration Date", "Registrar", "Registrar IANA ID", "Registrar Abuse Contact Phone", "Domain Status", "Registry Registrant ID", "Registrant Name", "Registrant Organization", "Registrant City", "Registrant State\/Province", "Registrant Postal Code", "Registrant Country", "Registrant Phone", "Registrant Fax", "Registrant Fax Ext", "Registrant Email"); $keysImploded = implode('|', $keys); $out = arrays(); while (preg_match('/(' . $keysImploded . '): (.*)/', $result, $matches)) { $out[] = $matches[1]; $result = $matches[2]; preg_match('/(.*?)((' . $keysImploded . ': |$).*)/', $result, $matches); $out[] = $matches[1]; $result = $matches[2]; } print_r($out); 

Produzione:

 Array ( [0] => Registrar WHOIS Server [1] => whois.publicdomainregistry.com [2] => Registrar URL [3] => www.publicdomainregistry.com [4] => Updated Date [5] => 2012-05-30T12:18:42Z [6] => Creation Date [7] => 2010-09-12T14:54:29Z [8] => Registrar Registration Expiration Date [9] => 2016-09-12T14:54:29Z [10] => Registrar [11] => PDR Ltd. d/b/a PublicDomainRegistry.com .... ) 

Questo approccio, tuttavia, richiede che tu sappia in anticipo quali (possibili) chiavi ci sono nella string dei risultati whois e che quei nomi di chiavi seguiti da due punti e uno spazio (es. "Registrar:") non si verificano in nessuna parte delle stringhe di valore.