Warning: include(../includes/header_geek.php) [function.include]: failed to open stream: No such file or directory in /home/itl0220/public_html/askthecomputergeek/code_explode_command.php on line 16

Warning: include(../includes/header_geek.php) [function.include]: failed to open stream: No such file or directory in /home/itl0220/public_html/askthecomputergeek/code_explode_command.php on line 16

Warning: include() [function.include]: Failed opening '../includes/header_geek.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/itl0220/public_html/askthecomputergeek/code_explode_command.php on line 16

Using the explode command

To give an example of how to use the explode command to isolate a value:

How to use php's explode command to get the value you want...

First you want to set your value to a variable: $xyz = "www.domain.com";
Note that this could be the value from a query or a server variable or hard coded as the example above.

Next decide what you are dividing the variable by and use the following syntax: $abc=explode("criteria", $xyz);
So in this example we are going to choose a period $abc=explode(".", $xyz); to create three values, www, domain, and com respectively.

Now you can use the following variables to display the following values: $abc[0] would equal www, $abc[1] would equal domain, and $abc[2] would equal com.

You can use this syntax to perform many tasks. Take the example that you need the house number from a street address. Assuming your value string is set to the variable $address...
explode(" ", $address); would allow you to use $address[0] to use the house number as a value.


Warning: include(../includes/bottom_ad.php) [function.include]: failed to open stream: No such file or directory in /home/itl0220/public_html/askthecomputergeek/code_explode_command.php on line 47

Warning: include(../includes/bottom_ad.php) [function.include]: failed to open stream: No such file or directory in /home/itl0220/public_html/askthecomputergeek/code_explode_command.php on line 47

Warning: include() [function.include]: Failed opening '../includes/bottom_ad.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/itl0220/public_html/askthecomputergeek/code_explode_command.php on line 47

Warning: include(../includes/bottom.php) [function.include]: failed to open stream: No such file or directory in /home/itl0220/public_html/askthecomputergeek/code_explode_command.php on line 48

Warning: include(../includes/bottom.php) [function.include]: failed to open stream: No such file or directory in /home/itl0220/public_html/askthecomputergeek/code_explode_command.php on line 48

Warning: include() [function.include]: Failed opening '../includes/bottom.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/itl0220/public_html/askthecomputergeek/code_explode_command.php on line 48