xpath.php : xpath XML PHP

 
<?php
   $xml = simplexml_load_file("books.xml");
   $authors = $xml->xpath("/library/book/author");
   foreach($authors AS $author) {
      echo "$author<br />";
   }
?>
  
  

wordwrap() requires one argument, the string to be transformed. : wordwrap String PHP

 
By default, wordwrap() wraps lines every 75 characters and uses n as its line-break character. 


<?php
$string = "this is a test.this is a test.this is a test.this is a test.this is a test.this is a test.";
$string .= "this is a test.this is a test.this is a test.this is a test.this is a test.this is a test.";
print wordwrap($string);
?>
  
  

while loop and mysql_fetch_array() function : mysql_fetch_array MySQL Database PHP

 
<html>

 <head>
  <title>Get data</title>
 </head>

 <body>

 <?php

 $conn = @mysql_connect( "localhost", "userName", "password" ) or die( "Err:Conn" );

 $rs = @mysql_select_db( "my_database", $conn )  or die( "Err:Db" );

 $sql = "select id,first_name from my_table order by first_name";

 $rs = mysql_query( $sql, $conn );

 while( $row = mysql_fetch_array( $rs ) )
 {
   echo( "ID: " . $row["id"] );
   echo( " - FIRST NAME: " . $row["first_name"] . "<br>" );
 }

 ?>

 </body>

</html>