Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Function cal in eregi_replace()

Posted on 2002-07-19
3
Medium Priority
?
276 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:
Richard Quadling earned 400 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:Richard Quadling
ID: 7169686
Thank you.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

972 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