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

  • SEARCH
  • Home
  • 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 6800197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:56:25+00:00 2026-05-26T18:56:25+00:00

I have this piece of code: <?php $pattern = /<span\b[^>]*>(.*?)</; $html = file_get_contents(http://www.bicicletapublica.com.ar/mapa.aspx); $results

  • 0

I have this piece of code:

<?php

$pattern = "/<span\b[^>]*>(.*?)</";
$html = file_get_contents("http://www.bicicletapublica.com.ar/mapa.aspx");
$results = array();
preg_match_all($pattern, $html, $results );
$results  = $results[0];
$stations = array();

for($i = 0; $i < count($results)-1;$i++){
    if(!($i & 1)){
        $key = strtolower(str_replace(" ","_",substr($results[$i], 0, -1)));
        $stations["$key"] = str_replace("Cant. Bicicletas disponibles: ","",substr($results[$i+1], 0, -1));

    }
}
print_r($stations);
print_r($stations["retiro"])
?>  

And I’m getting this error:

Array ( [retiro] => 40 [aduana] => 26 [derecho] => 27 [plaza_roma] => 8 [plaza_italia] => 29 [parque_lezama] => 31 [obelisco] => 28 [congreso] => 7 [parque_las_heras] => 17 [uca_puerto_madero] => 27 [tribunales] => 25 [plaza_vicente_lopez] => 23 [once] => 27 [pacifico] => 19 [virrey_cevallos] => 26 [plaza_houssay] => 2 [plaza_de_mayo] => 6 [plaza_almagro] => 21 [cmd] => 7 [independencia] => 9 [plaza_san_martin] => 21 )

Notice: Undefined index: retiro in /opt/lampp/htdocs/mejorenbici/index.php on line 17

As you can see, the key retiro was defined, but I don’t understand why the undefined index error is triggered.

  • 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-26T18:56:26+00:00Added an answer on May 26, 2026 at 6:56 pm

    Look at the HTML source code of the notice (not: error). When running your code in the console with php -a, I am getting:

    Array (
      [<span_class="style1">retiro] => <span class="style2">40
      [<span_class="style1">aduana] => <span class="style2">26
      [<span_class="style1">derecho] => <span class="style2">27
      [<span_class="style1">plaza_roma] => <span class="style2">8
      [<span_class="style1">plaza_italia] => <span class="style2">29
      [<span_class="style1">parque_lezama] => <span class="style2">31
      [<span_class="style1">obelisco] => <span class="style2">28
      [<span_class="style1">congreso] => <span class="style2">7
      [<span_class="style1">parque_las_heras] => <span class="style2">17
      [<span_class="style1">uca_puerto_madero] => <span class="style2">27
      [<span_class="style1">tribunales] => <span class="style2">25
      [<span_class="style1">plaza_vicente_lopez] => <span class="style2">23
      [<span_class="style1">once] => <span class="style2">27
      [<span_class="style1">pacifico] => <span class="style2">19
      [<span_class="style1">virrey_cevallos] => <span class="style2">26
      [<span_class="style1">plaza_houssay] => <span class="style2">2
      [<span_class="style1">plaza_de_mayo] => <span class="style2">6
      [<span_class="style1">plaza_almagro] => <span class="style2">21
      [<span_class="style1">cmd] => <span class="style2">7
      [<span_class="style1">independencia] => <span class="style2">9
      [<span_class="style1">plaza_san_martin] => <span class="style2">21
    )
    PHP Notice: Undefined index: retiro in - on line 19
    PHP Stack trace:
    PHP   1. {main}() -:0
    

    Do not parse HTML by applying only one Regular Expression only one time; use a markup parser (which can make use of Regular Expressions for greater efficiency).

    Do you have permission to reuse that data?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code on a php page, at the bottom: window.opener.location.href=/index.html;
Actually I have this piece of HTML code <form method=POST action=dosomething.php> <fieldset> <legend>My account</legend>
I have this piece of code: <li class=selected><a href=/AmIACandidate.html>Am I a Candidate?</a></li> I need
Let's say I have this little piece of code: <?php $tmp = str_split('hello world!',2);
I'm using this piece of code I found ( http://impnerd.com/wordpress-hack-add-post-images-to-your-homepage ) to display the
I have this piece of PHP code: <?php $username=$_POST['username']; $password=$_POST['password']; if($username&&$password){ $connect=mysql_connect(localhost,root,) or die(
I have this piece of code: function MyFunction() { $.ajax({ type: POST, url: ajax.php,
I have this JQuery piece of code. I want to see wht php outputs.
I have this piece of code <?php for ($i=0;$i<sizeof($list[tags]); $i++) { if ($list[tags][$i][title]=='list') {
I have this piece of code in my cms: <ul class=subsection_tabs id=tab_group_one style=clear:none;> <?php

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.