Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4570406
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:21:25+00:00 2026-05-21T19:21:25+00:00

I am new to PHP and I am trying to work on this one

  • 0

I am new to PHP and I am trying to work on this one problem where the middle of a URL changes.

For instance using this fake URL,

$url = 'http://www.bobsplace.com/events/georgetown/12354544233123';

I need to be able to substitute “georgetown” out with a random variable.

So I guess I need to like slice the URL after events, have a variable where “georgetown” would be, and then have the rest of the URL continue after it. I hope I am making as much sense as possible.

Alright,
I tried all these and still go errors, but most likely it is due to my current coding. I am entering the entire thing in now.

<?

// This URL only shows future events

$url = 'https://graph.facebook.com/192674347443031/events?access_token=153420758043439|66d692f0e73ad17d939d9d9c-1045402872|8VHLfMb3gYY0p9fnT7wMS8Q9Krc&expires_in=0&since=yesterday' ;

$event_id = get_post_custom_values('facebook_id');
$url = str_replace('/192674347443031/', '/' . $event_id . '/', $url);


$json = file_get_contents($url) ;

$data = json_decode( $json,true) ; 
//var_dump($data) ; 

$sorted_array = array_reverse($data['data'], TRUE) ; 

foreach ($sorted_array as $key => $value) {

    //print_r($value) ; 
    ?>

<? echo "<li><a href='http://facebook.com/event.php?eid=". $value['id']  . "' target='_blank'>" ;  
                                        echo "<h2>" .  $value['name'] . "</h2>" ;
                                        echo "</a>" ;
                                        echo " (" . $value['location'] .") <br />" ; 
                                        echo date("F j, Y, g:i a" , strtotime($value['start_time'])) . " to " . date("F j, Y, g:i a" , strtotime($value['end_time'])) ;?>
                                    <div class="moreinfo">    
                                     <? echo "<a href='http://facebook.com/event.php?eid=". $value['id']  . " ' target='_blank'>" ; 
                                        echo "<b>" .  'More info' . "</b>" ;
                                        echo "</a>" ;?>
                                        </div>
                                        <? echo "</li>"; 


}



?>

The errors I keep getting are now saying my array_reverse() should be an array. And also invalid argument foreach()

Now this is not the entire code on that page, but this is the snippet that is giving me problems.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:21:26+00:00Added an answer on May 21, 2026 at 7:21 pm

    I think you’re trying to say that you want to replace the text “georgetown”. If that’s correct, the following code should work (make sure you’ve defined $replace to what you want to replace it with):

    $url = str_replace('/georgetown/', '/' . $replace . '/', $url);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to php and MySQL and I'm having a problem trying to work
I am new to PHP and trying to get the following code to work:
I am new to php and I am getting this error trying to load
I am new to php and trying to write a login function. Bit stuck
I'm new to PHP and trying to get my head around security. I have
I am pretty new to PHP and I am trying to make an inventory
I'm painfully new to PHP, and was trying to set up phpBB on my
I'm trying to create a new project in NetBeans PHP from existing sources. When
I have a new install of Ubuntu and trying to use the php's mail()
I'm trying to learn how to use oop in php. I'm also fairly new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.