Solved

Function cal in eregi_replace()

Posted on 2002-07-19
3
240 Views
Last Modified: 2012-05-04
Greetings all,

I need to call a function each time php replaces a string with ergei_replace. here is the code:

     # Mathes %HZE_*
     $RX_E_P = '%HZE_([[:alpha:]/_0-9]*)';
     # Mathes %HZI_*
     $RX_I_P = '%HZI_([[:alpha:]/_0-9]*)';
     # Mathes <HAZEL_DATE[*]>|<HAZEL-DATE[*]>
     $RX_D_P = '(<[[:space:]]*HAZEL_DATE[^>]*>)|(<[[:space:]]*HAZEL-DATE[^>]*>)';
     $DATE_VAR = 'HZDATE';
     reset($StringTemp);
     while(list($k,$v)=each($StringTemp))
     {
          if(eregi($RX_E_P,$v) && $v = str_replace('"','',eregi_replace($RX_E_P, (STRING) h3m_get("QUERY","\\1") ,$v)))
          {
               echo "$v\n";
               #$outTemp[$k] = '"'.h3m_get("QUERY","$v").'"';
          }
          elseif(!eregi($RX_D_P,$v) || !$outTemp[$k] = eregi_replace($RX_D_P,h3m_get("QUERY","$DATE_VAR"),$v))
          {
               $outTemp[$k] = $v;
          }

I Know that PHP is not calling the function because I have the function set to echo each time it is called and it isn't echoing.
thanks
~Jay
0
Comment
Question by:Deathead
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
RQuadling earned 100 total points
ID: 7169544
Can you try ...

while(list($k,$v)=each($StringTemp))
    {
    echo "$k=$v<br>";
    ...

just to make sure you are splitting correctly.


What does the h3m_get function return. Echo this out as well ...

while(list($k,$v)=each($StringTemp))
    {
    echo "$k=$v<br>" . h3m_get("QUERY","\\1") . "<br>" . h3m_get("QUERY","$DATE_VAR") . "<br>";
    ...

You might simply be missing some parenthesis...

Try ...


while(list($k,$v)=each($StringTemp))
    {
    if(eregi($RX_E_P,$v) && ($v = str_replace('"','',eregi_replace($RX_E_P, (STRING) h3m_get("QUERY","\\1") ,$v))))
         {
              echo "$v\n";
              #$outTemp[$k] = '"'.h3m_get("QUERY","$v").'"';
         }
         elseif(!eregi($RX_D_P,$v) || !($outTemp[$k] = eregi_replace($RX_D_P,h3m_get("QUERY","$DATE_VAR"),$v)))
         {
              $outTemp[$k] = $v;
         }
     }

Regards,

Richard.

P.S. what sort of values are you putting into $StringTemp and what is coming out of h3m_get?
0
 

Author Comment

by:Deathead
ID: 7169680
Richard,

I thank you for your comment. I have already found the proper solution which was to use the preg_replace() with the 'e' modifyer.

I will still award the points as your comments show that you were most definately trying to help.

Thank you again,
~Jay
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 7169686
Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now