Solved

Function cal in eregi_replace()

Posted on 2002-07-19
3
235 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 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

13 Experts available now in Live!

Get 1:1 Help Now