473,672 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A problem with '"'

I have written a code and can't figure what is wrong, the code will
read a content of a file and cut all the emails from it,then echo them,
but I have a problem with '"' charecter I think..
Take a look:
*************** *************
<?php
$url="http://www.bihstudenti .com/kontakt.php";
$lines = file_get_conten ts($url);
$done=explode(" @",$lines);
for($i=0;$i<cou nt($done)+1;$i+ +)
{
$j=$i+1;
$a=strrpos($don e[$i],":");
$b=strrpos($don e[$i],">");
$c=strpos($done[$j],chr(34));
$d=strpos($done[$j],"<");
$front=$done[$i];
$back=$done[$j];
if($a>$b){
if($c<$d){
echo "Line $i
".substr($front ,strrpos($front ,":")+1)."@".su bstr($back,0,st rpos($back,chr( 34)))."<br>";
}else{
echo "Line $i
".substr($front ,strrpos($front ,":")+1)."@".su bstr($back,0,st rpos($back,"<") )."<br>";
}
}else{
if($c<$d){
echo "Line $i
".substr($front ,strrpos($front ,">")+1)."@".su bstr($back,0,st rpos($back,chr( 34)))."<br>";
}else{
echo "Line $i
".substr($front ,strrpos($front ,">")+1)."@".su bstr($back,0,st rpos($back,"<") )."<br>";
}
}
}
?>
*************** *************
I am looking at www.bihstudenti.com/kontakt.php content..
Please help, do any one have a clue what is wrong..

Oct 22 '05 #1
15 1926
NurAzije wrote:
read a content of a file and cut all the emails from it,then echo them,


Sorry, can't be bothered to check the code :) but try this:

$data = file_get_conten ts('http://www.bihstudenti .com/kontakt.php');
$match = array();
preg_match_all( '/mailto:([^"]+)">/', $data, $match);
print_r($match[1]);

See http://php.net/preg-match-all

--
E. Dronkert
Oct 22 '05 #2
It have succeded for the after mailto: ones, thank you very much, I am
a beginner in PHP, I dont know to play with these '/mailto:([^"]+)">/'
is there some tutorials to lern this about charecters or something..
Thank you...

Oct 22 '05 #3
NurAzije wrote:
a beginner in PHP, I dont know to play with these '/mailto:([^"]+)">/'


It's a "Regular Expression".
Start at http://php.net/manual/en/ref.pcre.php

--
E. Dronkert
Oct 22 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

NurAzije wrote:
$lines = file_get_conten ts($url);
$done=explode(" @",$lines);


I think here lies your problem. explode() expects its second parameter to be
an string, but you are feeding it an array (file() always returns an
array). As a result of the automatic type casting, $done may be empty
everytime yourun the script.

You can either:
- - Use array_map to apply the explode() function to every element from
$lines, and then array_merge the results,
- - or use file_get_conten ts() instead of file(), that returns a string.

As usual, more information in php.net/manual ...

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

http://acm.asoc.fi.upm.es/~mr/
Proudly running Debian Linux with 2.6.12-1-686 kernel, KDE3.4.2, and PHP
5.0.5-3 generating this signature.
Uptime: 12:47:15 up 15:50, 2 users, load average: 0.38, 0.43, 0.35

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDWhlK3jc Q2mg3Pc8RAsboAJ 9jjcxTe0DLSC4UG hctFISP3ItfBwCf VENu
c+TD9oiDNhjcYxA wYQoo5Qw=
=knA6
-----END PGP SIGNATURE-----
Oct 22 '05 #5
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

NurAzije wrote:

Oh, and, by the way:
for($i=0;$i<cou nt($done)+1;$i+ +)
Always use foreach() to transverse array: it's quite more secure (doesn't
miss any array keys, even if non-numeric) and compact (i.e. readable).

[...] $a=strrpos($don e[$i],":");


Also, if you are not going to use variable expansion (putting a variable
name inside a double-quote-enclosed string), use single quotes instead. It
saves the script a very small little bit of parsing time (that always
helps).

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

"If you haven't got anything nice to say about anybody, come sit next to
me."
- Alice Roosevelt Longworth (1884-1980)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDWhnT3jc Q2mg3Pc8RAoyYAJ 9ozRD4EwSuHe9lK 3QSUFIe2+ZIiQCf fluZ
/b3Z0xAOSf64CnbG 3z8tFK0=
=SdHn
-----END PGP SIGNATURE-----
Oct 22 '05 #6
Iván Sánchez Ortega wrote:
NurAzije wrote:
$lines = file_get_conten ts($url);
$done=explode(" @",$lines);


I think here lies your problem. explode() expects its second parameter to be
an string, but you are feeding it an array (file() always returns an
array). [...]
or use file_get_conten ts() instead of file(), that returns a string.


He did!

--
E. Dronkert
Oct 22 '05 #7
The expresions way is better, thanks ..
Now I must construct an expression that has an @ at the middle, and ><
at the sides, or spaces or " ", there is a list but the base is the
same ..

Oct 22 '05 #8
I am trying to write the expression like this, but something seems
wrong:
preg_match_all( '/(<|:| |").+@.+\....(> | |")/', $data, $match);
as follows :
(<|:| |") -- < or : or space or "
..+ -- any number of any charecters
@ -- is the @ in the email
..+ -- any number of any charecters
\. -- an escape for the dot
.... -- any three characters
(>| |") -- > or space or "

Any help please

Oct 22 '05 #9
NurAzije wrote:
preg_match_all( '/(<|:| |").+@.+\....(> | |")/', $data, $match);


Greedy/non-greedy problem, I guess. (Also, you should enclose the part
that you *do* want to match in brackets, or the matches won't show up as
separate entries in $match.) Try '/[a-z0-9_.+-]+@[a-z0-9.-]+/i'.

--
E. Dronkert
Oct 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1997
by: Simon | last post by:
Hi, I'm trying to serialize an XML document to a file using XERCES-C++ 2.1.0 . The Document contains an internal DTD. The DTD contains some elements with default values like the following snippet: <!ELEMENT SFLOPTRECPATTERN (#PCDATA)> <!ATTLIST SFLOPTRECPATTERN
11
4651
by: Frag | last post by:
Hi guys, I searched around without any clear answer. Tons of stuff, but nothing concrete. I am trying to call this Javascript function: function ButtonClicked() { alert("The button has been clicked."); }
3
3637
by: NecroJoe | last post by:
I am using PHP to generate a little javascript for one of my pages. In short it allows a user to select a value from a list and pop it into a form field on a seperate page. This works well unless there is a " or ' in the character string. <SCRIPT language=JavaScript> function Add_Term(SearchTerm) { window.opener.document.advsearch.name_title.value += SearchTerm; window.close();
5
2988
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig <<<<<<<<<<<<<<CODE>>>>>>>>>>>>>>>> <html>
1
1920
by: Jeff | last post by:
I am getting Unable to find operator in query string. Query string currently is INSERT INTO Results (Name,Email,Comments,File) VALUES ('::Name::','::Email::','::Comments::','::File::') Here is the ASP Code..From Frontpage. <html>
5
3432
by: martin | last post by:
Hi, I would be extremly grateful for some help on producing an xml fragemt. The fragment that I wish to produce should look like this <Addresses> <Address>&qout;Somebody's Name&quot; &lt;me@mydomain.com&gt;</Address> </Addresses>
1
4552
by: nishac | last post by:
I am using fckeditor 2.3.The problem is that i use shift-enter between paragraphs.But when i see it in the browser I can see double space instead of single space. I noticed that the source of fckeditor is creating a single <br>tag. <font size="3" color="#000000"><span bold="&quot;&quot;&quot;&quot;&quot;&quot;" font-style="&quot;&quot;&quot;&quot;&quot;&quot;" italic="&quot;&quot;&quot;&quot;&quot;&quot;" color="&quot;&quot;&quot;&quot;&quot;&quot;"><font size="4" color="#000080"> Maintenance &amp; Reliability Professional Review Course<br /> But the browser...
1
2793
by: Webstorm | last post by:
Hi, I hope someone can help me sort this out a bit, Im completely lost. Here is the page I am working on: http://www.knzbusinessbrokers.com/default.asp I have 3 search critera that I need to use when querying the database. Right now it is only looking for a match on one of those dropdowns and not all 3. can anyone help? Here is the code: <form BOTID="0" METHOD="POST" action="businessforsale_interface/Results/test3.asp">
2
1507
by: fran7 | last post by:
Hi, I wonder if anyone can see whats going wrong here. I have this line of asp and javascript and it works fine <a onmouseover="doTooltip(event,'<img src=&quot;<%=Server.URLPathEncode(rsCard("largeimage"))%>&quot; border=&quot;0&quot;><div class=&quot;tp2&quot;></div>' )" onmouseout="hideTip()" href="http://<%=rsCard("DefaultHeadline")%>" onclick="this.target='blank'"><img border="1px" src="<%=Server.URLPathEncode(rsCard("imageone"))%>" ...
3
3331
by: cketcham | last post by:
All, I have the following code: use 5.010; use LWP::UserAgent; use URI::URL; use LWP::Debug qw(+); my $browser = LWP::UserAgent->new();
0
8423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8645
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,...
0
8699
tracyyun
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...
0
7479
agi2029
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...
1
6261
isladogs
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...
0
5722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4245
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...
1
2844
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
2
2097
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.