Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Php explode not working on wamp

Featured Replies

Php explode not working on wamp

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Two Col</title>

<link rel="stylesheet" type="text/css" href="style.css" />
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 <script type="text/javascript" src="prototype.js"></script>
 <script type="text/javascript" src="HelpBalloon.js"></script>
</head>
<body>
<?
$rawPhoneNumber = "800-555-5555"; 

$phoneChunks = explode("-", $rawPhoneNumber);
echo "Raw Phone Number = $rawPhoneNumber <br />";
echo "First chunk = $phoneChunks[0]<br />";
echo "Second chunk = $phoneChunks[1]<br />";
echo "Third Chunk chunk = $phoneChunks[2]";
?>


</body>
</html>

Php explode not working on wamp

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Two Col</title>

<link rel="stylesheet" type="text/css" href="style.css" />
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 <script type="text/javascript" src="prototype.js"></script>
 <script type="text/javascript" src="HelpBalloon.js"></script>
</head>
<body>
<?
$rawPhoneNumber = "800-555-5555"; 

$phoneChunks = explode("-", $rawPhoneNumber);
echo "Raw Phone Number = $rawPhoneNumber <br />";
echo "First chunk = $phoneChunks[0]<br />";
echo "Second chunk = $phoneChunks[1]<br />";
echo "Third Chunk chunk = $phoneChunks[2]";
?>


</body>
</html>

 

What exactly is not working? Because not even looking more thoroughly: depending on configuration of Apache/PHP it might not recognize your opening/closing php tags, why don't you use <?php ?>

Try cleaning up a little and see if it works:

<?php

$rawPhoneNumber = "800-555-5555"; 

$phoneChunks = explode("-", $rawPhoneNumber);
echo ("Raw Phone Number = " . $rawPhoneNumber . " <br />");
echo ("First chunk = " . $phoneChunks[0] . "<br />");
echo ("Second chunk = " . $phoneChunks[1] . "<br />");
echo ("Third Chunk chunk = " . $phoneChunks[2]);

?>

Edited by neverminder

Assuming

 

$phoneChunks = explode("-", $rawPhoneNumber);die(var_dump($phoneChunks))

 

gives you an array its because your using array values in a string tis all... you can use the curly brackets to use array values in double quoted strings :)

 

 

$phoneChunks = explode("-", $rawPhoneNumber);
echo "Raw Phone Number = $rawPhoneNumber <br />";
echo "First chunk = {$phoneChunks[0]}<br />";
echo "Second chunk = {$phoneChunks[1]}<br />";
echo "Third Chunk chunk = {$phoneChunks[2]}";

Edited by SniderDK

  • Author

What exactly is not working? Because not even looking more thoroughly: depending on configuration of Apache/PHP it might not recognize your opening/closing php tags, why don't you use <?php ?>

Try cleaning up a little and see if it works:

<?php

$rawPhoneNumber = "800-555-5555"; 

$phoneChunks = explode("-", $rawPhoneNumber);
echo ("Raw Phone Number = " . $rawPhoneNumber . " <br />");
echo ("First chunk = " . $phoneChunks[0] . "<br />");
echo ("Second chunk = " . $phoneChunks[1] . "<br />");
echo ("Third Chunk chunk = " . $phoneChunks[2]);

?>

thanks that worked

this isn't a big thing, but if your not putting variables right into the string then using single quotes is the correct string encapsulation.

 

echo ("First chunk = {$phoneChunks[0]}<br />");
// or
echo ('First chunk = ' . $phoneChunks[0] . '<br />');

 

both work of course but in different ways in PHP

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.