Hi All, I'm trying to use explode to separate the result of a textual
file, but it explode me only the first row.
the foo.txt is
pippo pluto
pluto pippo
pippo pippo
....
I use this script found in http://it2.php.net/manual/en/function.explode.php
$pizza = "/var/www/foo.txt";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2 4 2669
sorry.. this is the correct one:
$pizza = "/var/www/foo.txt";
$lines = file('/var/www/foo.txt');
foreach ($lines as $line_num =$line) {
htmlspecialchar s($line) . "<br />\n";
$pieces = explode(" ", htmlspecialchar s($line) . "<br />\n");
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
}
it echoes only the first line of the file
pippo pluto
On 24 Mar, 09:39, "Davide" <davide.papa... @gmail.comwrote :
sorry.. this is the correct one:
$pizza = "/var/www/foo.txt";
$lines = file('/var/www/foo.txt');
foreach ($lines as $line_num =$line) {
htmlspecialchar s($line) . "<br />\n";
$pieces = explode(" ", htmlspecialchar s($line) . "<br />\n");
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
}
it echoes only the first line of the file
pippo pluto
Ok.. I solved...
It was the space in <br />
$pizza = "/var/www/foo.txt";
$lines = file('/var/www/foo.txt');
foreach ($lines as $line_num =$line) {
htmlspecialchar s($line) . "<br>\n";
$pieces = explode(" ", htmlspecialchar s($line) . "<br>\n");
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
}
Davide wrote:
On 24 Mar, 09:39, "Davide" <davide.papa... @gmail.comwrote :
>sorry.. this is the correct one:
$pizza = "/var/www/foo.txt"; $lines = file('/var/www/foo.txt'); foreach ($lines as $line_num =$line) { htmlspecialchar s($line) . "<br />\n"; $pieces = explode(" ", htmlspecialchar s($line) . "<br />\n"); echo $pieces[0]; // piece1 echo $pieces[1]; // piece2 }
it echoes only the first line of the file
pippo pluto
Ok.. I solved...
It was the space in <br />
$pizza = "/var/www/foo.txt";
$lines = file('/var/www/foo.txt');
foreach ($lines as $line_num =$line) {
htmlspecialchar s($line) . "<br>\n";
$pieces = explode(" ", htmlspecialchar s($line) . "<br>\n");
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
}
Well, you seemed to solved it all by yourself. :-)
Now have a nice pizza. :P
Regards,
Erwin Moller
On 26 Mar, 14:05, Erwin Moller
<since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
Davide wrote:
On 24 Mar, 09:39, "Davide" <davide.papa... @gmail.comwrote :
sorry.. this is the correct one:
$pizza = "/var/www/foo.txt";
$lines = file('/var/www/foo.txt');
foreach ($lines as $line_num =$line) {
htmlspecialchar s($line) . "<br />\n";
$pieces = explode(" ", htmlspecialchar s($line) . "<br />\n");
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
}
it echoes only the first line of the file
pippo pluto
Ok.. I solved...
It was the space in <br />
$pizza = "/var/www/foo.txt";
$lines = file('/var/www/foo.txt');
foreach ($lines as $line_num =$line) {
htmlspecialchar s($line) . "<br>\n";
$pieces = explode(" ", htmlspecialchar s($line) . "<br>\n");
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
}
Well, you seemed to solved it all by yourself. :-)
Now have a nice pizza. :P
Regards,
Erwin Moller
Yes! Just RTFM carefully :)
Hope it helps someone...
:P This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rob Gudgeon |
last post by:
Hi
Is it possible to explode a string into an array using more than one
separator? I have database records that contain several values, mostly split
by semi-colons but some older records are split by comma.
It's obviously no hassle if I have to explode twice but it'd be nice if I
could do it with one line...
cheers, Rob
|
by: William Krick |
last post by:
I have a string containing concatenated ascii "records" that are each
terminated by '\n'.
For testing purposes, I construct sample data like this...
$mystring = "a|b|c|d\n"."e|f|g|h\n"."i|j|k|l\n"."m|n|o|p\n";
I want to use explode() to put the records into an array like this...
|
by: Richard Lawrence |
last post by:
Hi there,
I'm having a problem with PHP which I'm not sure how to best solve.
Here is the code:
$fp = fopen("comments.txt", "r");
while(!feof($fp))
{
$line = fgets($fp, 1024);
list($key, $value) = explode(":", $line, 2);
|
by: frizzle |
last post by:
Hi there,
i have a site with fake folders & files.
htaccess rewrites everything to index.php?vars
now in index.php i decide what file to include with a switch/case
statement.
to define where i am, i explode the query string, and check $array
where i am for the main section.
Only now if there are two slashes behind each other
|
by: FFMG |
last post by:
Hi,
I need the php equivalent of explode in one of my app.
I read a very big file and "explode" each line to fill a structure.
The reading of the file, 19Mb, (I will also need to streamline the way
I read each line I guess), takes about 10 seconds. But when I 'explode'
each line the process takes about 140 seconds.
This is what I have tried so far...
| |
by: k04jg02 |
last post by:
Python has a nifty operator that will take a container and pass its
elements as function parameters. In Python you can make a list like
so:
x =
Then you can say:
f(*x)
|
by: Jack |
last post by:
I would like to Explode a string into an array that does not begin at
0 but I can't get it to work.
For example: $MyInfo = array(1 =27,68,31,19,40);
will result in $MyInfo = 27 ... $MyInfo = 40
But, I'd like to process a string: "27,68,31,19,40" such that it would
get the same result.
I tried:
|
by: sathyashrayan |
last post by:
Dear group,
The function to be used as follows:
$links = "http://www.campaignindia.in/feature/analysis";
$tag1 = '<div class=feature-wrapper>';
$tag2 = '<h1><a href';
$tag3 = "</a>";
$op = doGetTags($links,"START",$tag1,$tag2,$tag3,"END");
|
by: vinpkl |
last post by:
hi all
i want to use explode url for shotening my urls
i have a url like
http://localhost/vineet/products.php?dealer_id=12&category_id=2
This is my navigation php code that has url explode function in while statement
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |